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!
Judy

Gallery version: 2.2.2
PHP version:
PHPInfo Link:
Webserver: 1.3.37 (Unix)
Database: MySQL version 5.0.27
Activated toolkits: ImageMagick, NetPbm, GD
Operating system (e.g. Linux): Linux
Browser (e.g. Firefox 2.0): Firefox 2.0.0.8
Theme: carbon
http://www.nichollsfamily.us/gallery/

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 10113
Posted: Fri, 2007-10-26 19:54
{if empty($theme.parents)}
stuff on root album only
{/if}

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

Login or register to post comments
judyn

Joined: 2007-10-25
Posts: 16
Posted: Fri, 2007-10-26 20:17

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

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 10113
Posted: Fri, 2007-10-26 20:33
Quote:
I finally found it by looking at the debug tree. Surely there is another way?

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

Login or register to post comments
cimbus

Joined: 2007-07-02
Posts: 11
Posted: Wed, 2007-10-31 11:41

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.

Login or register to post comments
cimbus

Joined: 2007-07-02
Posts: 11
Posted: Fri, 2007-11-02 22:23

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.

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 10113
Posted: Sat, 2007-11-03 00:01
Quote:
Is there a smarty method how to do it?
Quote:
A smarty method to see if you have positioned elements? I don't understand.

Login or register to post comments
cimbus

Joined: 2007-07-02
Posts: 11
Posted: Sat, 2007-11-03 19:01

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?

Login or register to post comments
floridave
floridave's picture

Joined: 2003-12-22
Posts: 10113
Posted: Sat, 2007-11-03 22:24

{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

Login or register to post comments
cimbus

Joined: 2007-07-02
Posts: 11
Posted: Sun, 2007-11-04 19:54

Thanks Dave, exactly what I needed.

Login or register to post comments
charmedworks

Joined: 2007-07-03
Posts: 3
Posted: Thu, 2007-12-20 18:40

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.

Login or register to post comments