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 😉 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. 😉
Usage V1.0.2
{exp:if_homepage}
{if is_homepage}
This is the home-page
{if:else}
This isn't the home-page
{/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
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.
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 😉 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
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!
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 😉
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.
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 bewithout needing the plugin syntax around it. Anywho… just wishing… wishing up a star!{if mb_is_homepage} TRUE {if:else} FALSE {/if}
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
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.
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:Even though this is technically still the homepage, the plugin thinks this is not.http://www.site.com/?gclid=CL_H2Jm5x5QCFSQyusyrNbeflg
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]
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>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.