Slightly different style for index page Slightly different style for index page
 

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

Slightly different style for index page

Started by Bent Wooden Spoon, September 09, 2011, 12:03:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bent Wooden Spoon

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:

<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:

<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.

Αndré

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

Bent Wooden Spoon

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:


<div id="examplesitenav">
<ul>
<li id="not_a_ link">Not a link</li>
</ul></div>


And on every other gallery page look like:


<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.

Αndré

Quote from: Bent Wooden Spoon on September 09, 2011, 07:10:17 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:


<div id="examplesitenav">
<ul>
<li id="not_a_ link">Not a link</li>
</ul></div>


And on every other gallery page look like:


<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).

Bent Wooden Spoon

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:


        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!

Bent Wooden Spoon

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.

Αndré

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


Quote from: Bent Wooden Spoon on September 13, 2011, 01:05:12 PM
So my problem is effectively sorted.
Quote from: Joachim Müller on September 28, 2008, 12:46:26 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.

Bent Wooden Spoon

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:



$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:



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.

Stramm

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'

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

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

Αndré

Quote from: Joachim Müller on September 28, 2008, 12:46:26 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.