Fruity theme Fruity theme
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Fruity theme

Started by antisa33, February 24, 2005, 08:02:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

antisa33

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

Joachim Müller

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

antisa33

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

Joachim Müller

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

antisa33

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 !!

donnoman

find in your theme.php in the pageheader function:

        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],


replace with:

        '{GAL_DESCRIPTION}' => my_gal_description(),


somewhere above the pageheader function declare and populate your custom function

function my_gal_description()
{
    ob_start();
        echo 'Hello World!';
    return ob_get_clean();
}






donnoman

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.


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;
}

antisa33

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 !! :)

antisa33

 :)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

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;
}

donnoman

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.


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?


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.

antisa33

Thanks a lot donnoman !
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

donnoman

http://www.php.net/substr


$rest = substr("abcdef", 0, -1);  // returns "abcde"


So part of your function could look like this:


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