How do I add something only to the main page?
|
judyn
Joined: 2007-10-25
Posts: 16 |
Posted: Fri, 2007-10-26 19:44
|
|
I have added a flickr slideshow to my gallery page by modifying album.tpl. However, I would like it to show only on the main page and not on each gallery page. I did a search and didn't come up with anything. There must be some if statement that I can put around it to implement this? Thanks so much! Gallery version: 2.2.2 |
|
| Login or register to post comments |

Posts: 10113
{if empty($theme.parents)} stuff on root album only {/if}Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 16
Thanks so much, floridave!
Just after I posted I found a solution in another thread, but yours is better because it's specific to the root album.
Others reading this thread might find the other solution useful though because it can target a particular page:
{if $theme.item.id == 7}
whatever I want here
{/if}
I had some trouble finding the theme ID. I finally found it by looking at the debug tree. Surely there is another way?
Judy
Posts: 10113
The smarty debug popup, when you have debug turned on will give you a bunch more info.
turning off the rewrite module will give you the itemId as well:
Example.com/gallery2/main.php?g2_itemId=31
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 11
Till now I was using this:
{php}
$queryString = $_SERVER['QUERY_STRING'];
if ($queryString == '') {
echo '
<div id="">ONLY MAIN PAGE EXTRA CONTENT</div>
';}
{/php}
But floridave´s is really SMARTY.
Posts: 11
If the {if empty($theme.parents)}stuff on root album only{/if} method is used the extra stuff is visible in the whole admin section, as my extra stuff is absolute positioned this is not good. Is there a smarty method how to do it? Untill solved I changed it back to my {php} QUERY_STRING method.
Posts: 10113
Posts: 11
The original Question: How do I add something only to the main page?
You suggested the code {if empty($theme.parents)}stuff on root album only{/if}.
But I got the problem that using this code the stuff on root album only (in my case a positioned element) is also visible in the entire admin section which is not wanted as the stuff could be placed just to the main page i.e. the very first page (main.php without any string).
The PHP script I posted is fine for me, just was looking for a smarty equivalent. Or does the switching between PHP and smarty (if I put a small PHP in my template) slow the performance down?
Posts: 10113
{if $theme.pageType == 'admin'}on admin page only{/if}will show on the admin page.so I guess you would want:
{if empty($theme.parents)} {if $theme.pageType != 'admin'} stuff on root album only and not a admin page {/if} {/if}I hope I am understanding
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 11
Thanks Dave, exactly what I needed.
Posts: 3
Just a note to give props to this helpful post.
Thanks floridave! This is exactly what I needed to complete a client request: works great on the highly modified Carbon theme we're using.