Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-07-17 13:31:58

stag*
Member
From: Germany
Registered: 2018-06-16
Posts: 10

[SOLVED] Sticky article on section page

Hello,

I would like to achieve the following: A section page which displays a list of articles that displays a sticky article as introductory content. That bit I have done so far. Seems to work fine. However, when I jump to page 2 with older articles the sticky is displayed again on top of the list. Is there any way to avoid this behaviour? Many thanks for any useful hints. Already spent hours on this…

Boris

Page template looks like this.

<txp:if_article_list>
<txp:article_custom status="sticky" limit="1" form="my_form" />
<txp:article form="article_listing" limit="5" />
<txp:else />
<txp:article limit="5" form="my_form"/>
</txp:if_article_list>

Last edited by stag* (2018-07-17 13:32:16)

Offline

#2 2018-07-17 16:03:44

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

Re: [SOLVED] Sticky article on section page

I’m wondering if a variable would help.

<txp:if_article_list>
<txp:variable name="plink" value='<txp:permlink />'  />
<txp:if_variable name="pilink" value="http://www.your_site.tld/section_name/">
<txp:hide>Replace the value with the exact url of the front page of the section</txp:hide>
<txp:article_custom status="sticky" limit="1" form="my_form" />
<txp:article form="article_listing" limit="5" />
<txp:else />
<txp:article form="article_listing" limit="5" offset="5" />
</txp:if_variable>
<txp:else />
<txp:article limit="5" form="my_form"/>
</txp:if_article_list>

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

Offline

#3 2018-07-17 16:09:14

stag*
Member
From: Germany
Registered: 2018-06-16
Posts: 10

Re: [SOLVED] Sticky article on section page

OK, accidentally stumbled into another thread and got inspired for a different approach using variables:

<txp:if_article_list>
    <txp:variable name="page" value='<txp:page_url type="pg" />' />
	<txp:if_variable name="page" value="1">
		<txp:article status="sticky" limit="1" />
		<txp:article form="article_listing" limit="3" />
    <txp:else />
		<txp:article form="article_listing" limit="5" />
    </txp:if_variable>
</txp:if_article_list>

This seems to work well, but strangely despite more than 6 live-articles being present some are not displayed when browsing to page 2 now. I have to admit this is a bit trial and error for myself – so it’s very likely I’m on the wrong path. Still any useful hints and ideas are more than welcome.

B*

Offline

#4 2018-07-17 16:15:17

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,609
Website

Re: [SOLVED] Sticky article on section page

You might have more luck with txp:page_url and type="pg", e.g. something like this (shamelessly building on Yiannis’ code):

<txp:if_article_list>
    <!-- article list page -->
    <txp:variable name="pagenum" value='<txp:page_url type="pg" />'  />
    <txp:if_variable name="pagenum" value="1">
        <!-- show sticky only if page number is 1 -->
        <txp:article status="sticky" limit="1" form="my_intro_form" />
    </txp:if_variable>
    <!-- your regular article list -->
    <txp:article form="article_listing" limit="5" />
<txp:else />
    <!-- your individual article form -->
    <txp:article limit="5" form="my_form"/>
</txp:if_article_list>

TXP Builders – finely-crafted code, design and txp

Offline

#5 2018-07-17 16:16:10

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,609
Website

Re: [SOLVED] Sticky article on section page

Hehe, you found it without my help ;-)


TXP Builders – finely-crafted code, design and txp

Offline

#6 2018-07-17 16:17:04

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

Re: [SOLVED] Sticky article on section page

Hi Boris,

What do you mean with

but strangely despite more than 6 live-articles being present some are not displayed when browsing to page 2 now.

ie. Do you see the first 3 articles on the homepage of the section and another 3-4 on the next page of the section?


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

Offline

#7 2018-07-17 16:35:37

stag*
Member
From: Germany
Registered: 2018-06-16
Posts: 10

Re: [SOLVED] Sticky article on section page

Hello Yiannis, hello Jakob.
Many thanks for looking into this.

- Yiannis approach with permlink unfortunately didn’t do the job. Just gave me a single article in listform in return.
- Just tried Jakob’s suggestion – It works! Thank you!
The difference to my own second approach is the position of the </txp:if_variable> before the actual non-sticky article call…

This also solved the other issue I experience with the ommitting of some articles.

Thanks again. That saved my evening! :-)

Offline

#8 2018-07-18 10:53:29

etc
Developer
Registered: 2010-11-11
Posts: 5,062
Website GitHub

Re: [SOLVED] Sticky article on section page

stag* wrote #313042:

I would like to achieve the following: A section page which displays a list of articles that displays a sticky article as introductory content. That bit I have done so far. Seems to work fine. However, when I jump to page 2 with older articles the sticky is displayed again on top of the list. Is there any way to avoid this behaviour?

Possibly another way to achieve this in 4.7 (untested):

<txp:if_article_list type="pg"><!-- typically pg=2,3,... -->
    <txp:article limit="5" form="my_form"/>
<txp:else />
    <txp:article_custom status="sticky" limit="1" form="my_form" />
    <txp:article form="article_listing" limit="5" />
</txp:if_article_list>

Offline

Board footer

Powered by FluxBB