Advanced search  

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

Pages: [1]   Go Down

Author Topic: Conditional if album_ID  (Read 8220 times)

0 Members and 1 Guest are viewing this topic.

treret

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Conditional if album_ID
« on: November 29, 2019, 10:53:37 am »

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
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Conditional if album_ID
« Reply #1 on: November 29, 2019, 11:49:50 am »

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

PASTE your div after

Code: [Select]
  CPGPluginAPI::action('theme_thumbnails_wrapper_start', null);

Code: [Select]
       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.
« Last Edit: December 10, 2019, 05:19:00 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Conditional if album_ID
« Reply #2 on: November 29, 2019, 11:54:53 am »

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?
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Conditional if album_ID
« Reply #3 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.
Logged

treret

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Conditional if album_ID
« Reply #4 on: November 29, 2019, 04:12:40 pm »

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
Logged

treret

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Conditional if album_ID
« Reply #5 on: November 29, 2019, 05:12:01 pm »

Hi,

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

I would like only registered users see that.

Thanks
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Conditional if album_ID
« Reply #6 on: December 10, 2019, 05:21:50 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.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Conditional if album_ID
« Reply #7 on: December 10, 2019, 05:24:04 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.

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.
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.