Conditional if album_ID Conditional if album_ID
 

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

Conditional if album_ID

Started by treret, November 29, 2019, 10:53:37 AM

Previous topic - Next topic

0 Members and 5 Guests are viewing this topic.

treret

Hi,

I would like to put a <div></div> with different content depending on the album ID (e.g. ...../thumbnails-25.html something,  ...../thumbnails-30.html something different).

I know is something like this for the admin:

      <?php if (USER_IS_ADMIN) { ?> X <?php  } else { ?> Y <?php } ?>

but, what is the

if (...... )

for albums ID?

Thank you

allvip

#1
1) In function <<<theme_display_thumbnails>>> (if is not in your theme copy it from themes/sample/theme.php)

PASTE your div after


  CPGPluginAPI::action('theme_thumbnails_wrapper_start', null);



       if ($CURRENT_ALBUM_DATA['aid'] == 1) {
echo '<div class="your_custom_class">custom content</div>';
      } elseif  ($CURRENT_ALBUM_DATA['aid'] =2) {echo '<div class="your_custom_class">custom content</div>';} 
      elseif  ($CURRENT_ALBUM_DATA['aid'] =3) {echo '<div class="your_custom_class">custom content</div>';}


and so on for all the albums you need.

allvip

Recopy the code above.
I edit it.
Had a small mistake.

You want everybody to see the custom divs or only you or registred users?

ron4mac

I would approach it in a different way by creating a plugin that does 2 things:
  Adds an additional, editable field to album properties...
  and displays that content in the appropriate place.

treret

Hi allvip,

I don't know why, but my topic was moved from coppermine 1.5 support to coppermine 1.6 support (I have 1.5).

Maybe is for this that it's not working. It gives for all albums the same first custom content (in your exemple that for aid = 1) as if it were not the IF STATEMENT at all..

Thanks

treret

Hi,

it works perfectly, I only had to change = to ==.

I would like only registered users see that.

Thanks

allvip

Quote from: ron4mac on November 29, 2019, 02:25:41 PM
I would approach it in a different way by creating a plugin that does 2 things:
  Adds an additional, editable field to album properties...
  and displays that content in the appropriate place.

Maybe one day I will start making plugins.

allvip

Quote from: treret on November 29, 2019, 05:12:01 PM
Hi,

it works perfectly, I only had to change = to ==.
Hi.
I updated the code and I wanted to move the topic from cpg1.5 miscellaneous to cpg1.5 visual.
By mistake I moved it to 1.6, but the code works for both versions.

Quote from: treret on November 29, 2019, 05:12:01 PM
Hi,
I would like only registered users see that.

Thanks

Not possible.
The forum is even to help everybody learn from other users questions.
Sorry.