NEW Plugin - If Homepage…
Posted: 04 July 2008 04:47 AM   [ Ignore ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

EDIT - Add Actually the Ternary operation is working fine. I’m just too tired to realise that I was checking against false instead of true. All should work fine hopefully for everyone?

Okay a nice easy one this one in relation to this thread over here.

Please bear in mind that this was written in under 1 minute so hopefully it should do as it says on the tin wink I’m still a little confused as I swear that my ternary operator condition in the plugin is working back to front but it seems to be working on my system so hopefully it will elsewhere too. wink

Usage V1.0.2

{exp:if_homepage}

{if is_homepage}
<p>This is the home-page</p>
{if:else}
<p>This isn't the home-page</p>
{/if}

{/exp:if_homepage} 


Usage V1.0.1

{exp:if_homepage}

{if true}
This is the home
-page
{if
:else}
This isn
't the home-page
{/if}

{/exp:if_homepage} 


Usage V1.0

{exp:if_homepage}

{if fail}
This isn
't the home-page
{if:else}
This is the home-page
{/if}

{/exp:if_homepage} 

That’s it basically. Hope it works for everyone and hope it’s of some use.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 04 July 2008 06:50 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  555
Joined  04-23-2008

Mark,

You’re a machine man! Simple, but useful.

Profile
 
 
Posted: 04 July 2008 07:03 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  305
Joined  04-12-2008

Hey Mark, well done, seems very useful.

Just a tiny remark: in terms of usability, it would make more sense if the syntax was:

{exp:if_homepage}

{if true}
    This is the homepage
{if
:else}
    This isn
't the homepage
{/if}

{/exp:if_homepage} 

Or even

{if {exp:if_homepage}}
    This is the homepage
{if
:else}
    This isn
't the homepage
{/if} 

Don’t know if the latter is possible in EE.

 Signature 

gridonic | Twitter


URL Field Extension
Required Category Extension
DC FreeForm GeoIP Extension
DC Template Manager

Profile
 
 
Posted: 04 July 2008 07:18 AM   [ Ignore ]   [ # 3 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Hiya,

You are absolutely right that I have the condition a bit upside down. Will look at that a bit later on and upload the new version. wink

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 04 July 2008 07:26 AM   [ Ignore ]   [ # 4 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Okay updated!

Hopefully should work. Let me know if I’ve done something wonky!!

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 04 July 2008 07:32 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  555
Joined  04-23-2008

Seriously Mark.. What kind of caffeine do you drink? You’re on here more than I am.. That’s INCREDIBLE.

Profile
 
 
Posted: 04 July 2008 07:49 AM   [ Ignore ]   [ # 6 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

No caffeine for me. I’m strictly a soft drinks sort of guy. Fly helis so can’t afford to mess with my body too much! wink

Plus I hate the smell of coffee and other caffeine based products grin

Is it all working for everyone? The plugin I mean grin

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 06 July 2008 08:09 AM   [ Ignore ]   [ # 7 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Slight update to the plugin.

Now changed conditional to {if is_homepage} instead of {if true}. Hopefully this is a better fit?

Updated file in top post.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 13 July 2008 01:34 PM   [ Ignore ]   [ # 8 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1757
Joined  03-26-2006

For the record, the newest version is listed as 1.0.2, but the version number in the $plugin_info array still says 1.0.1.

And does every version note require an emoticon?

 Signature 

ryan masuga
—————
Masuga Design | devot:ee
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 13 July 2008 01:49 PM   [ Ignore ]   [ # 9 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Hi Ryan,

Thanks for the heads up on the version number. The reason was that I made the swap between 1.0.1 and 1.0.2 quite close between each other and so basically forgot wink Fixed now though.

Not too sure what you mean by the emoticons though? Perhaps the ones in the plugin notes? Sorry if that is not the right thing to do? No offence was intended by it.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 15 July 2008 01:22 AM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  368
Joined  01-20-2006

Nice one mark. Just came across a great use for this.
And I *LOVE* that you’re keeping all version available in the parent. I wish more add-ons kept all versions available.

Anywho, good work.

I’d even think it’d be easier if you could create a global variable, only if you’re at the homepage.
So, do your query magic to see if you’re at the home page.
And then your code could be

{if mb_is_homepage}
TRUE
{if
:else}
FALSE
{
/if} 

without needing the plugin syntax around it.

Anywho… just wishing… wishing up a star!

 Signature 

AJ Penninga
Pretty Squares, LLC - http://www.prettysquares.com

Profile
 
 
Posted: 15 July 2008 06:53 AM   [ Ignore ]   [ # 11 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006
AJP - 15 July 2008 05:22 AM

Nice one mark. Just came across a great use for this.

Excellent. Thanks for the kind words and glad that it has found some uses wink

AJP - 15 July 2008 05:22 AM

And I *LOVE* that you’re keeping all version available in the parent. I wish more add-ons kept all versions available.

Anywho, good work.

Yep like to keep everything in the one place making it easier for everyone to find what they are looking for.

AJP - 15 July 2008 05:22 AM

I’d even think it’d be easier if you could create a global variable, only if you’re at the homepage.
So, do your query magic to see if you’re at the home page.
And then your code could be

{if mb_is_homepage}
TRUE
{if
:else}
FALSE
{
/if} 

without needing the plugin syntax around it.

Anywho… just wishing… wishing up a star!


Not too sure how I would go about doing that because as far as I know to use a plugin you have to have the surrounding plugin tags. Would be great if that could be done but I don’t know how that is possible.

Anyway glad you found a use for it.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile
 
 
Posted: 17 July 2008 01:55 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1757
Joined  03-26-2006

Just to note that this doesn’t work if you’re trying to use Google AdWords. My client has an incoming link like this from certain Google searches:

http://www.site.com/?gclid=CL_H2Jm5x5QCFSQyusyrNbeflg 

Even though this is technically still the homepage, the plugin thinks this is not.

 Signature 

ryan masuga
—————
Masuga Design | devot:ee
@masuga | @masugadesign | @devot_ee

Profile
 
 
Posted: 16 July 2009 05:04 PM   [ Ignore ]   [ # 13 ]  
Grad Student
Rank
Total Posts:  31
Joined  02-05-2009
mdesign - 17 July 2008 05:55 PM

Just to note that this doesn’t work if you’re trying to use Google AdWords. My client has an incoming link like this from certain Google searches:

http://www.site.com/?gclid=CL_H2Jm5x5QCFSQyusyrNbeflg 

Even though this is technically still the homepage, the plugin thinks this is not.

I’ve been struggling with this for quite some time but recently discovered how to use mod_rewrite to combat this. It might not be the best way but it seems to work for me so far…

# Remove session ID's from URL
Options +FollowSymLinks
RewriteCond 
%{QUERY_STRING} ^(.+)?sid=[a-z0-9]+(&?.*)$
RewriteRule ^(.*)$ /$1?%1 [L,R=301] 
Profile
 
 
Posted: 16 June 2010 01:10 PM   [ Ignore ]   [ # 14 ]  
Summer Student
Avatar
Total Posts:  7
Joined  12-03-2007

Does this work for EE2? Can’t seem to get it to work. I’m using inbetween the title tag but expressionengine says:

The following tag has a syntax error:

{exp:if_homepage}

Please correct the syntax in your template.

I’ve used this and it seems to work:

<title>
  
{if segment_1==""}
  {site_name}
  {if
:else}
  {site_name}{exp
:channel:entries rdf="off" limit="1"{title}{/exp:channel:entries}
  {
/if}
  
</title
Profile
 
 
Posted: 16 June 2010 01:41 PM   [ Ignore ]   [ # 15 ]  
Professor
Avatar
RankRankRankRankRankRankRank
Total Posts:  13771
Joined  04-15-2006

Hiya,

The plugin won’t work with 2.0 as I haven’t updated it for use in 2.0

You can however get around it by doing as you have done above though.

Best wishes,

Mark

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors

Profile