Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-01-13 10:08:52

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 6,258
Website

section front page

Is there a native way (without plugins) to have a front page for a section and have a link to page 2 where the section’s articles are listed (txp:article_list)? Basically I am looking for a native alternative to glx_if_section_frontpage.


Yiannis
——————————
neme.org | hblack.net | LABS | NeMe @ github

Online

#2 2018-01-13 11:04:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 7,911
Website

Re: section front page

glx_if_section_frontpage just tests two thing:

1. If we’re NOT on a catgeory page (txp:page_url type="c" /> is empty)
2. If the article ID not set (txp:page_url type="id" /> is empty)

So through judicial use of that tag and some <txp:variable /> magic you should be able to simulate the effect with native tags. Not time to try it right now, sorry.


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 2018-01-13 11:36:51

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 6,258
Website

Re: section front page

Would this be it?

<txp:if_section name="my_section">
<txp:variable name="isnotcategory" value='<txp:page_url type="c" />' />
<txp:variable name="hasnoid" value='<txp:page_url type="id" />' />
<txp:if_variable name="isnotcategory" value="">
<txp:if_variable name="hasnoid" value="">
is section front page
<txp:else />
is section second page?
</txp:if_variable>
</txp:if_variable>
</txp:if_section>

Yiannis
——————————
neme.org | hblack.net | LABS | NeMe @ github

Online

#4 2018-01-13 12:16:12

etc
Developer
Registered: 2010-11-11
Posts: 2,407
Website

Re: section front page

If I get it right, you want some special output on the first page? Not tested, but you can try a negative offset:

<txp:variable name="page" value='<txp:page_url type="pg" />' />

<txp:if_variable name="page" value="1">
    frontpage
<txp:else />
    <txp:article limit="10" offset="-10" />
</txp:if_variable>

<!-- older/newer links and other stuff -->

etc_[ query | search | pagination | date | tree | cache ]

Offline

#5 2018-01-13 15:03:11

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 7,911
Website

Re: section front page

My first thought was to try and harness the pg attribute to differentiate “first page” but I couldn’t figure out the logic in the limited time I had.

On reflection, we have <txp:if_article_list> and <txp:if_category> which might be more useful tests than checking the <txp:page_url /> parts (although you’d need to nest the conditionals).

I did have a fleeting thought about whether we could introduce some additional types that would help here, but I’m conscious of the tag becoming a catch-all. Perhaps we need to empower a container tag that can output (or test) a bunch of stuff in the current context. e.g:

  • Is this the front page?
  • Is it a landing page?
  • Are we in a list context for a particular content type?

In essence, it’d work like a combination of the if_* tags we have now, perhaps even supersede them one day. Drat, it’s starting to sound like a simpler version of smd_if ;-)


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

#6 2018-01-14 07:09:50

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,273
Website

Re: section front page

Hi,

I have allways used

<txp:if_section name="">

to test homepage, but never used it for pagination stuff then dont know if it works.

Cheers.

Offline

#7 2018-01-14 11:11:24

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 2,664
Website

Re: section front page

Does glx_if_section_front_page give you what you want to achieve?

If so, this tag combo – based on Stef’s suggestion – should give you the same:

<txp:if_article_list>
  <txp:if_category>
    <!-- category list page -->
    <txp:article />
  <txp:else />
    <!-- section front page -->
    <txp:article status="sticky" />
  </txp:if_category>
<txp:else />
  <!-- individual article -->
  <txp:article />
</txp:if_article_list>

That differentiates between the section front page and category list and individual article pages, but I don’t know if you can achieve what you want to without assigning all the “second page” articles to a category (e.g. “section-articles”) and your front page article(s) to status = sticky.

etc’s suggestion sounded altogether neater if it works.


TXP Builders – finely-crafted code, design and txp

Offline

#8 2018-01-15 16:26:47

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 6,258
Website

Re: section front page

Hi guys,

Firstly, thank you all very much for your suggestions.

After a lot of deliberation I have managed to persuade our committee that we did not need a second page to the section after all.

Details: The newsletter page in our main site needed to have links to our latest emails (a list compiled using rah_external in our legacy site with the postmaster plugin). The suggestion was to have the links first and click another link for the form. I argued that fewer clicks is better and all information is now in the same page.


Yiannis
——————————
neme.org | hblack.net | LABS | NeMe @ github

Online

#9 2018-01-15 20:31:01

etc
Developer
Registered: 2010-11-11
Posts: 2,407
Website

Re: section front page

Bloke wrote #308649:

On reflection, we have <txp:if_article_list> … which might be more useful tests than checking the <txp:page_url /> parts … I did have a fleeting thought about whether we could introduce some additional types that would help here

I actually like this idea, and it was more than time to simplify the “frontpage” detection. Now, e.g. <txp:if_article_list type="c, month, pg" /> additionally checks if any of category, month or pg is set. This allows for flexible frontpage definitions, is backwards compatible and extensible to URL parameters, please test.

jakob wrote #308653:

etc’s suggestion sounded altogether neater if it works.

It works quite well, if you don’t mind ?pg=2 actually outputting the first page of articles. But with the above-mentioned commit one can distinguish between /section/ and /section/?pg=1 URL. Something like this should work now:

<txp:if_article_list type="author, c, month, pg, q"> <!-- not section frontpage -->
    <txp:article />

    <!-- shift appends pg parameter to all page links, even the first one -->
    <txp:newer shift /> - <txp:older />
<txp:else />
    <txp:article pgonly /> <!-- set up pagination -->
    <txp:article status="sticky" />

    <!-- shift="0" outputs the current page link with pg parameter appended -->
    <txp:older shift="0" />
</txp:if_article_list>

etc_[ query | search | pagination | date | tree | cache ]

Offline

#10 2018-01-16 09:11:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 7,911
Website

Re: section front page

Nice one, Oleg. Seems as if shift acts like a page offset to add/subtract from the pg param. Would the attribute name offset be more in line with our current tags? Or is that too confusing?


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

Board footer

Powered by FluxBB