Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Fruity theme  (Read 4603 times)

0 Members and 1 Guest are viewing this topic.

antisa33

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 181
    • Free french kids coloring
Fruity theme
« on: February 24, 2005, 08:02:19 pm »

Hello i have the fruity theme and at the top i have in the template.html
{GAL_NAME}
{GAL_DESCRIPTION}
How can i do to change the content of {GAL_NAME}
{GAL_DESCRIPTION} when i change of page ?
I would like to have all pages top different text. Is it possible ?
thanks for all your work!!
Isa
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Fruity theme
« Reply #1 on: February 25, 2005, 09:52:04 am »

the stuff in curly braces are just place holders. {GAL_NAME} and {GAL_DESCRIPTION} are being replaced with what you have set up in coppermine config for "Gallery name" and "Gallery description". You can add any static text there that you can imagine. Dynamic content can't go into the file template.html, there has to be some advanced changes to the code, can only tell you details if you post what you want to accomplish, along with a link to your page.

Joachim
Logged

antisa33

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 181
    • Free french kids coloring
Re: Fruity theme
« Reply #2 on: February 25, 2005, 03:45:07 pm »

Thanks for your response.
I want to create a table with a lot of sentence.
At the top, instead of {GAL_DESCRIPTION} i would like to have a random sentence of my table.
Where can i modifiy ? I think i have to put my sql query in theme.php?
Thank you !
(It's for http://coloriages.enfant.free.fr ) french
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Fruity theme
« Reply #3 on: February 25, 2005, 04:27:20 pm »

not that easy - if you have created the db, you should be able to code the query as well. To get the content created from your query to display anywhere on your theme, look up the board: search for "custom header".

Joachim
Logged

antisa33

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 181
    • Free french kids coloring
Re: Fruity theme
« Reply #4 on: March 16, 2005, 07:54:41 pm »

Thanks gaugau .
i have searched "custom header" but it's not with sql code.
Me i would like to place sql code and put the result at the top instead of {GAL_DESCRIPTION}
Thank you !!
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Fruity theme
« Reply #5 on: March 16, 2005, 09:42:13 pm »

find in your theme.php in the pageheader function:
Code: [Select]
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],

replace with:
Code: [Select]
        '{GAL_DESCRIPTION}' => my_gal_description(),

somewhere above the pageheader function declare and populate your custom function
Code: [Select]
function my_gal_description()
{
    ob_start();
        echo 'Hello World!';
    return ob_get_clean();
}




Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Fruity theme
« Reply #6 on: March 16, 2005, 10:00:29 pm »

this code kind of addresses what you are asking about how to read a table that you have setup in sql and output it; This code is not from coppermine itself but a plugin. I removed a lot of fluff to make it more readable.

Code: [Select]
function minicms($content='')
{
    global $thisplugin, $MINICMS, $CONFIG, $cat, $album, $REFERER, $lang_minicms;
    ob_start();
    $where = (isset($MINICMS['ID'])) ?  "ID='{$MINICMS['ID']}'" : "conid='{$MINICMS['conid']}' AND type='{$MINICMS['type']}'";
    $query = "SELECT * FROM {$CONFIG['TABLE_CMS']} WHERE $where ORDER BY cpos";
    $result = db_query($query);

    while ($cms = mysql_fetch_assoc($result)) {
        $cms_array[]=$cms;
    }
    mysql_free_result($result);
    foreach ($cms_array as $key => $cms) {
        $cms['content'] = html_entity_decode(stripslashes($cms['content']));
        starttable("100%", $cms['title']);
        print <<<EOT
        <tr><td class="tableb">
        {$cms['content']}
        </td></tr>
EOT;
        endtable();
    }

    $content.=ob_get_contents();
    ob_end_clean();
    return $content;
}
Logged

antisa33

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 181
    • Free french kids coloring
Re: Fruity theme
« Reply #7 on: March 18, 2005, 04:42:13 pm »

Thank you donnoman i really appreciate your help.
i will need you code last.
I would like to put the album description at the top instead of {GAL_DESCRIPTION} but when i put {ALB_DESC} in template.html , it prints {ALB_DESC} instead of the description.
What have i to change ?
Thanks !! :)
Logged

antisa33

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 181
    • Free french kids coloring
Re: Fruity theme
« Reply #8 on: March 20, 2005, 06:48:04 pm »

 :)This is my fonction : it takes 6 albums names to put instead of {GAL_DESCRIPTION} at the top
It's ok
thank you for all

Code: [Select]
function my_gal_description($content='')
{
    global $CONFIG;
    global $lang_errors;
    ob_start();
   
    $query = "SELECT title from cpg132_albums order by rand() limit 6";
    $result = db_query($query); 


if ((mysql_num_rows($result))) {
                $test ='';
            while($alb=mysql_fetch_array($result)){
                    $test .= 'coloriage '. $alb['title'].', ';
            }
}

        $content = $test;
   
EOT;
   
   

    $content.=ob_get_contents();
    ob_end_clean();
    return $content;
}
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Fruity theme
« Reply #9 on: March 20, 2005, 07:05:40 pm »

since your not passing anything to the function, and you aren't outputting anything via html, you're only returning a value you can simplify this.

This should work the same as what you had posted.

Code: [Select]
function my_gal_description()
{
    global $CONFIG;

    $query = "SELECT title from {$CONFIG['TABLE_ALBUMS']} order by rand() limit 6";
    $result = db_query($query);

    if ((mysql_num_rows($result))) {
        $test ='';
        while($alb=mysql_fetch_array($result)){
                $test .= 'coloriage '. $alb['title'].', ';
        }
    }

    return $test;
}

And I'm not sure how you are using this but it might be helpful to limit the album names returned limited to the active category?

Code: [Select]
function my_gal_description()
{
    global $CONFIG, $cat;

    $query = "SELECT title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='$cat' ORDER BY rand() LIMIT 6";
    $result = db_query($query);

    if ((mysql_num_rows($result))) {
        $test ='';
        while($alb=mysql_fetch_array($result)){
                $test .= 'coloriage '. $alb['title'].', ';
        }
    }

    return $test;
}

Good Luck.
Logged

antisa33

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 181
    • Free french kids coloring
Re: Fruity theme
« Reply #10 on: March 30, 2005, 07:06:33 pm »

Thanks a lot donnoman !
Code: [Select]
while($alb=mysql_fetch_array($result)){ $test .= 'coloriage '. $alb['title'].', ';How can we do to don't have the "," at the end of the result ?
Thank you very much i put all my modifications when i do here.
Thank
Isa
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Fruity theme
« Reply #11 on: March 31, 2005, 05:30:08 am »

http://www.php.net/substr

Code: [Select]
$rest = substr("abcdef", 0, -1);  // returns "abcde"

So part of your function could look like this:
Code: [Select]

    if ((mysql_num_rows($result))) {
        $test ='';
        while($alb=mysql_fetch_array($result)){
                $test .= 'coloriage '. $alb['title'].', ';
        }
$test=substr($test, 0, -1);
    }
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 20 queries.