forum.coppermine-gallery.net

Support => cpg1.6.x Support => cpg1.6 themes (visuals) => Topic started by: treret on November 29, 2019, 10:53:37 am

Title: Conditional if album_ID
Post by: treret 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
Title: Re: Conditional if album_ID
Post by: allvip 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.
Title: Re: Conditional if album_ID
Post by: allvip 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?
Title: Re: Conditional if album_ID
Post by: 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.
Title: Re: Conditional if album_ID
Post by: treret 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
Title: Re: Conditional if album_ID
Post by: treret 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
Title: Re: Conditional if album_ID
Post by: allvip 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.
Title: Re: Conditional if album_ID
Post by: allvip 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.