Using a keyword to manipulate theme Using a keyword to manipulate theme
 

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]

Main Menu

Using a keyword to manipulate theme

Started by Caprisorn20, November 12, 2012, 02:15:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Caprisorn20

Is there a way to set a variable when keywords are read so that if a particular keyword is used some text is shown/not shown on the display page? Reason I ask is that I'd like to use a particular keyword and if it is present to not show Google Adsense on that page because the image may not adhere to the T&Cs.

On displayimage.php the keyword can be found within:
    if ($CURRENT_PIC_DATA['keywords'] != '') {
        $keyword_links = array();
        foreach (explode($CONFIG['keyword_separator'], html_entity_decode($CURRENT_PIC_DATA['keywords'])) as $keyword) {
            $keyword_links[] = '<a href="thumbnails.php?album=search&amp;keywords=on&amp;search=' . urlencode($keyword) . '">' . $keyword . '</a>';
            if($keyword=='blah') {$ADSENSE='off';}
        }
        $info[$lang_common['keywords']] = '<span class="alblink">' . implode(' / ', $keyword_links) . '</span>';
    }


I know  if($keyword=='blah') {$ADSENSE='off';} is not correct but what is the best way to make a global variable that can drive this ll the way through to theme.php?

Thanks in advance.

Jeff Bailey

#1
It's recommended that you edit theme files instead of core files so:

In your custom theme.php
you can add

/******************************************************************************
** Section <<<theme_display_image>>> - START
******************************************************************************/
function theme_display_image($nav_menu, $picture, $votes, $pic_info, $comments, $film_strip)
{
    global $CONFIG, $LINEBREAK, $CURRENT_PIC_DATA;

    $superCage = Inspekt::makeSuperCage();

    $width = $CONFIG['picture_table_width'];

    echo '<a name="top_display_media"></a>'; // set the navbar-anchor
    starttable();
    echo $nav_menu;
    endtable();

    starttable();
    echo $picture;
    endtable();

// start adsense
$keywordlist = explode($CONFIG['keyword_separator'],$CURRENT_PIC_DATA['keywords']);
if (!in_array('triggerword', $keywordlist)) {
echo 'code to display adsense';
}
//end adsense

    if ($CONFIG['display_film_strip'] == 1) {
        echo $film_strip;
    }


    echo $votes;

    $picinfo = $superCage->cookie->keyExists('picinfo') ? $superCage->cookie->getAlpha('picinfo') : ($CONFIG['display_pic_info'] ? 'block' : 'none');
    echo $LINEBREAK . '<div id="picinfo" style="display: '.$picinfo.';">' . $LINEBREAK;
    starttable();
    echo $pic_info;
    endtable();
    echo '</div>' . $LINEBREAK;

    echo '<a name="comments_top"></a>';
    echo '<div id="comments">' . $LINEBREAK;
        echo $comments;
        echo '</div>' . $LINEBREAK;

}
/******************************************************************************
** Section <<<theme_display_image>>> - END
******************************************************************************/

This will display your ad under the image description on displayimage.php


// start adsense
$keywordlist = explode($CONFIG['keyword_separator'],$CURRENT_PIC_DATA['keywords']);
if (!in_array('triggerword', $keywordlist)) {
echo 'code to display adsense'
}
//end adsense

Is the code I added. edit triggerword to match the keyword and change code to display adsense to your adsense code.

Of Course you can move the whole adsense block to wherever you want. If your adsense code is in a different part of your page, you'll have to find the proper function (or ask) and add the code and make $CURRENT_PIC_DATA a global variable.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford