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: Slightly different style for index page  (Read 3813 times)

0 Members and 1 Guest are viewing this topic.

Bent Wooden Spoon

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Slightly different style for index page
« on: September 09, 2011, 12:03:48 pm »

Apologies if this has been answered before, I've done a few searches and not managed to find a definitive answer or how-to.

I'm wanting to have some very slightly different HTML code in the index page from the rest of the gallery. My site has a navbar using images from a sprite map as buttons, which I've incorporated into my theme's template. When on my Coppermine home page I want the button to look depressed, and the link to be inactive. This is how my template behaves currently, using this code:

Code: [Select]
<li id="reflected"><span>Reflected</span></a></li>
What I then want is for every other page in the gallery to have the button as a different image (giving the appearance of it having popped back up) and  function as the home button for the gallery, my code for which is:

Code: [Select]
<li id="reflection"><a href="../../../../reflection/index.php"><span>Reflection</span></a></li>
Is there any way to achieve this? Apologies if it's obviously laid out in the docs and I'm being a muppet.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Slightly different style for index page
« Reply #1 on: September 09, 2011, 12:53:23 pm »

Please post a link to your gallery, as I cannot conceive how your gallery/navbar looks and what you try to accomplish.
Logged

Bent Wooden Spoon

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Slightly different style for index page
« Reply #2 on: September 09, 2011, 07:10:17 pm »

Thanks for the quick response.

Sorry, I appreciate it probably sounds confusing - ultimately it doesn't matter, the design itself isn't so important. I can't post a link as the site's not live, I'm working on a local testing server - I'd have linked it without being prompted had it been publically accessible.

In the simplest terms, is it possible to have a different template for the home page from the rest of the gallery, or is there some way to apply code that modifies the template for the home page only? I'd like to modify one CSS value and disable a link on the home page, and keep all other pages as they are.

In the case of my navbar (note, my own site's navbar I pasted into template.htm, not a Coppermine navbar), I'd like to be able to make the code on the home page look like:

Code: [Select]
<div id="examplesitenav">
<ul>
<li id="not_a_ link">Not a link</li>
</ul></div>

And on every other gallery page look like:

Code: [Select]
<div id="examplesitenav">
<ul>
<li id="link"><a href="link">link</a></li>
</ul></div>

If you still prefer I can send you the theme in a .zip, although as I've said the styling and the theme themselves don't actually matter all that much, but I can understand it might make things clearer.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Slightly different style for index page
« Reply #3 on: September 12, 2011, 03:26:54 pm »

In the case of my navbar (note, my own site's navbar I pasted into template.htm, not a Coppermine navbar), I'd like to be able to make the code on the home page look like:

Code: [Select]
<div id="examplesitenav">
<ul>
<li id="not_a_ link">Not a link</li>
</ul></div>

And on every other gallery page look like:

Code: [Select]
<div id="examplesitenav">
<ul>
<li id="link"><a href="link">link</a></li>
</ul></div>

In that case you should add a new token to the template.html file (e.g. {MY_CUSTOM_NAVBAR}) and replace it with the actual content inside the pageheader function. Have a look at this recent thread to get an idea how it works (unfortunately the thread is a little bit messed up).
Logged

Bent Wooden Spoon

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Slightly different style for index page
« Reply #4 on: September 13, 2011, 11:32:07 am »

Thanks again for the help. Had no idea the custom tokens would be quite so easy.

I'm still not sure how to make it so that custom token is only loaded on the home page and only the home page though. I'm probably going about it all wrong. If I add code to theme.php along the lines of:

Code: [Select]
        if (defined('THUMBNAILS_PHP')) {

$custom_navbar = 'A Navbar';}

else if (defined('INDEX_PHP')) {

$custom_navbar = 'Another Navbar';}

else {

        $custom_navbar = 'Yet Another Navbar';}

I can almost achieve what I want. The problem is the album list (/index.php?cat=0) obviously expressing the same navbar as the home page (index.php). So I don't think this is the right way to go about it.

So, basically, what would be the best way to have the custom token appear only in "domain/gallery/index.php", not any other pages at all?

Once again, thanks a lot!
Logged

Bent Wooden Spoon

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Slightly different style for index page
« Reply #5 on: September 13, 2011, 01:05:12 pm »

Okay, realised my album list and home pages looked identical anyway, so it doesn't actually impact on my theme. I've therefore just sidestepped the issue by getting rid of the album list button from the coppermine menu bar and using the homepage as the album list page so the defines I used in the code above work.

So my problem is effectively sorted. I'd still be interested to know of a cleaner way to do it for future reference though.

Thanks again for the custom tokens link.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Slightly different style for index page
« Reply #6 on: September 13, 2011, 01:46:09 pm »

You could check for parameters (e.g. if the cat parameter has been submitted) and then decide what to display.


So my problem is effectively sorted.
you can tag your answer as "solved" by clicking on the "Topic Solved" button on the bar at the left hand side at the bottom of your thread.
Logged

Bent Wooden Spoon

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Slightly different style for index page
« Reply #7 on: September 13, 2011, 02:56:29 pm »

Thanks again Andre. Glad you replied, as it does still affect my theme - when I view categories, unsurprisingly enough. Sorry for the slight lengthy post below, thought it would be best to show you the code I'm using in theme.php.

It's very inelegant, no doubt there's a much better way:

Code: [Select]

$link_navbar = '<ul class="navlist">
<li id="link"><a href="link.htm">Link</a></li>
</ul>';

$not_a_link_navbar = '<ul class="navlist">
<li id="notalink">Not A Link</li>
</ul>';

if (defined('DISPLAYIMAGE_PHP')) {
$custom_navbar = $link_navbar;}

if (defined('THUMBNAILS_PHP')) {
$custom_navbar = $link_navbar;}

else if (defined('INDEX_PHP')) {
$custom_navbar = $not_a_link_navbar;}

else {
$custom_navbar = $link_navbar;}

I was looking at the cid and cat parameters and thinking they're answer, but as you can probably tell from the code I posted above I barely have a clue with php, so I'm not sure what to implement. I'm assuming it's something like:

Code: [Select]

else if (defined('INDEX_PHP')) {

if (something relating to $cat?) {
$custom_navbar =$link_navbar;}

else {
$custom_navbar =$not_a_link_navbar;}

}

but nothing I've tried has worked.

Sorry again for being so much work, your effort's greatly appreciated.
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Slightly different style for index page
« Reply #8 on: September 13, 2011, 03:41:13 pm »

If you follow Αndrés advice and you code that into the pageheader function then add that below the global definitions.
If you're on the mainpage (on index.php and [cat is not defined or cat is 0]) then it's printing 'mainpage'

Code: [Select]
global $CPG_PHP_SELF, $superCage;

if ($CPG_PHP_SELF=='index.php' && (!$superCage->get->keyExists('cat') || $superCage->get->getInt('cat')==0)) {
echo "mainpage";
}

Bent Wooden Spoon

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: Slightly different style for index page
« Reply #9 on: September 13, 2011, 03:55:33 pm »

Perfect! That's it working great. Thanks yet again, you've both been a massive help.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Slightly different style for index page
« Reply #10 on: September 13, 2011, 04:04:57 pm »

you can tag your answer as "solved" by clicking on the "Topic Solved" button on the bar at the left hand side at the bottom of your thread.
Logged
Pages: [1]   Go Up
 

Page created in 0.067 seconds with 19 queries.