Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-03-05 17:52:26

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

if_homepage tag

The current situation to check whether viewing homepage is like so (I think):

<txp:if_search>
<txp:else />
    <txp:if_category>
    <txp:else />
        <txp:if_author>
        <txp:else />
            This is homepage only
        </txp:if_author>
    </txp:if_category>
</txp:if_search>

Shame we can’t just use a <txp:if_homepage /> tag instead of all that cruft.

Offline

#2 2015-03-06 00:01:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: if_homepage tag

It’s actually more involved than all of that when you factor in image_index lists and date-based archives. The nesting gets silly.

I’m all for pursuing this if we can nail down what exactly a home page is :-)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2015-03-06 07:17:22

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: if_homepage tag

Or maybe even an extra attribute in the if_section tag instead of a whole new tag.

Offline

#4 2015-03-06 09:26:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: if_homepage tag

philwareham wrote #288794:

Or maybe even an extra attribute in the if_section tag instead of a whole new tag.

How would that work, specifically? <txp:if_section> has name="" or name="default" for detecting the frontpage(ish), albeit you can’t currently tell if you’re in a special list context without your nested melée of tags.

If there was a new attribute, how would it work in conjunction with the name attribute so it still makes sense? e.g.:

<txp:if_section name="blog" is_frontpage="1">
   erm... does this make sense?
   First page of the blog section, maybe, without any pagination markers?
</txp:if_section>

or

<txp:if_section name="" is_frontpage="1">
   This is the home page without any:
     -> pagination markers
     -> category list
     -> author list
     -> search results
     -> image index list
</txp:if_section>

It’d be unable to cater for plugins that use the home page (like smd_tags) but that’s outside its scope anyway and the plugin’s own tags would need to be used there to further detect this situation.

I’m not fully comfortable with that kind of syntax at the moment, it feels like shoehorning to me. Perhaps you had a different idea? If we were going to go down that route, I’d be tempted to consider a more generic format where we could detect other types of page content. Examples:

<txp:if_section name="" context="landing">
   I'm the base frontpage, no context here (no cat, author, search, etc filter).
</txp:if_section>
<txp:if_section name="" context="search">
   I'm the same as <txp:if_search>.
</txp:if_section>
<txp:if_section name="" context="author">
   I'm the same as <txp:if_author>.
</txp:if_section>
<txp:if_section name="" context="any">
   I'm any default landing page with a filter in place (category, author, image_index, ...)
   but NOT the base home page.
</txp:if_section>
<txp:if_section name="blog" context="category">
   I'm a category landing page in the blog section.
   Same as <txp:if_category> in a section template.
</txp:if_section>
<txp:if_section name="blog" context="any">
   I'm any type of landing page (category, author,  etc) in the blog section.
</txp:if_section>
<txp:if_section name="blog" context="landing">
   I'm the /blog landing page, no special filters in use.
</txp:if_section>
<txp:if_section name="">
   Same as today, returns true for any context.
</txp:if_section>

That kind of thing. Not sure how to handle pagination. I mean, presumably the second page of older/newer results would not trigger context="landing", but it may trigger true for context="any" because it’s still a list after all. That doesn’t allow you to distinguish between the use cases of “being paged” or “first page of list”, but I’m not sure the <txp:if_section> tag is the right place for that kind of test anyway. Hmmmm.

Dunno, that might be messy or confusing, not really thought it through. Any advances on this or better suggestions?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2015-03-06 09:47:34

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: if_homepage tag

context attribute could work. I agree the is_frontpage attribute is not ideal.

Offline

#6 2015-03-06 13:45:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: if_homepage tag

philwareham wrote #288807:

context attribute could work. I agree the is_frontpage attribute is not ideal.

+1


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB