Check if the current url is the homepage
Posted: 06 February 2008 10:31 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  368
Joined  09-20-2006

Can someone tell me what the if statement would look like to check if the current page is the homepage?

I am using a conditional to display some content and I don’t want to display it on the homepage.

Thanks Much!

Jesse

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 06 February 2008 10:51 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6088
Joined  08-04-2002

The home page can be accessed via different URLs…

http://www.site.com/ ...or… http://www.site.com/index.php/
http://www.site.com/index.php/templateGroup/template/

So, you need to account for the variations…

{if segment_1 == “”}
{if segment_1 == “templateGroup”
AND segment_2 == “template”}

You can probably combine them…

{if segment_1 == “”} OR segment_1 == “templateGroup” AND segment_2 == “template”}

Profile
 
 
Posted: 06 February 2008 10:54 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  368
Joined  09-20-2006

Thanks PXLated,

I just checked to see if segment_1 was empty and redirected all my links to {homepage} so I don’t use any template groups in the url.  The homepage is just a single-entry template.

Thanks for the advice!

Jesse

 Signature 

“I am so clever that sometimes I don’t understand a single word of what I am saying.”

Profile
 
 
Posted: 03 July 2008 11:58 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006

I was just wondering this myself. I’ve always just used {if segment_1 == “”}, but I’ve found that on some sites that doesn’t work because I’m doing something on the homepage template that may require segment_1 to be blank, but one of those other conditions PXLated mentioned is true, so the page doesn’t work as it should.

Would be nice if there was a way to go: {if homepage}home!{/if} that would check all those conditions for you. I suppose it would be checking to see if you’re viewing the template that has the asterisk by it - the one designated as your homepage in the Control Panel.

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 04 July 2008 02:01 AM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6603
Joined  04-15-2006

EDIT - ADD Actually thinking about it that is just silly what I have said below as you would then be checking something against something you already know - Duh - not enough sleep again for me!!. Will have another think!

Could you not set a global variable to what you know is the correct homepage (even though there are different ways on different sites you will know on your site which is correct) and then perform a calculation against that?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 04 July 2008 02:48 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6603
Joined  04-15-2006

Okay give this a go then. Written in about 1 minute but hopefully should work.

If Homepage Plugin

I’m sure I have something wrong with my ternary operator in the plugin somewhere but I think it appears to be working properly. Let me know if it is any good.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65063 Total Logged-in Users: 47
Total Topics: 82196 Total Anonymous Users: 25
Total Replies: 441740 Total Guests: 243
Total Posts: 523936    
Members ( View Memberlist )
Newest Members:  1nvidiousjaris1skinnygirlaexermk1979Andrew_IDmdutahDanielJ8Forward GearCBlalock