Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Have section list page show a single article?
I’m sure this is covered, but my Google-fu won’t pull it up.
Say you have a section: about.
And when someone visits /about, you want the visitor to see a specific article, “about my company” as well as a list of other articles in the about section.
I think the Textpattern question is: How do you show a specific article in the article list context?
Offline
Re: Have section list page show a single article?
Hi,
check the code of our site on github, the particular template, linked to a section, more or less doing what you need. Regarding the list of articles, you could use either the related_articles or the article_custom tags.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Online
Re: Have section list page show a single article?
Another very simple way to front a section with some (introductory) text that you have stored in an article at the top of a section landing page, e.g. in an article list context, is to use a sticky article. An example:
- Write your About introduction, perhaps with its own heading, in an article and assign it to your
about
section. Set the status tosticky
and then save it. - Write your other individual articles in the about section and save as regular
live
articles assigned to that section. - In your page template, you can then do:
<!-- your lead article heading and text -->
<txp:article status="sticky" limit="1">
<h2><txp:title /></h2>
<txp:body />
</txp:article>
<!-- the regular article list / individual article view -->
<txp:article />
… which means the normal txp:article tag responds as normal to the article_list context or individual_article context as before, but on a list page, the content of a single sticky article will be shown at the beginning.
txp:article
on its own has status="live"
as default, so you don’t risk having duplicate content. As the sticky article doesn’t have a permlink in it, it never has its own page and only shows on the section landing page.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Have section list page show a single article?
You can also abuse sections description if 255 chars suffice:
<txp:meta_description type="section" format="" escape="textile" />
Offline
Re: Have section list page show a single article?
jakob wrote #318248:
Another very simple way to front a section with some (introductory) text that you have stored in an article at the top of a section landing page, e.g. in an article list context, is to use a sticky article. An example:
- Write your About introduction, perhaps with its own heading, in an article and assign it to your
about
section. Set the status tosticky
and then save it.- Write your other individual articles in the about section and save as regular
live
articles assigned to that section.- In your page template, you can then do:
<!-- your lead article heading and text -->...
… which means the normal txp:article tag responds as normal to the article_list context or individual_article context as before, but on a list page, the content of a single sticky article will be shown at the beginning.
txp:article
on its own hasstatus="live"
as default, so you don’t risk having duplicate content. As the sticky article doesn’t have a permlink in it, it never has its own page and only shows on the section landing page.
I have never been able to figure out how to keep a certain article at the top of the Home Page. Sticky seems the obvious choice but that does not do it. I tried to figure out the above without luck. I just did a new install and want to get it right the first time. Any help?
Regards, Nick
Offline
Re: Have section list page show a single article?
We should probably add <txp:article status="sticky" />
where appropriate to the default theme, to make it easier for new users: try to replace
<txp:if_variable name="front-page">
<!-- links by default to form: 'default.txp' unless you specify a different form -->
<txp:article limit="5" />
with
<txp:if_variable name="front-page">
<!-- links by default to form: 'default.txp' unless you specify a different form -->
<txp:article status="sticky" />
<txp:article limit="5" />
Then sticky articles should be displayed above the live ones.
Offline
Re: Have section list page show a single article?
etc wrote #318332:
We should probably add
<txp:article status="sticky" />
where appropriate to the default theme
Please raise an issue and I’ll make sure this gets added to the default theme. Thanks!
Offline
Re: Have section list page show a single article?
Thank You! That worked. I have another question which is related. I want to but a sticky article at the top of the Home Page, right now I only know how to do that by having a section made for the article. That section ends up being a tag on the nav bar. How can I hide that section from the nav bar and still have the article on the Home Page?
Regards, Nick
Offline
Re: Have section list page show a single article?
I appreciate the way you showed how to change the code!
etc wrote #318332:
We should probably add
<txp:article status="sticky" />
where appropriate to the default theme, to make it easier for new users: try to replace
<txp:if_variable name="front-page">...
with
<txp:if_variable name="front-page">...
Then sticky articles should be displayed above the live ones.
p.
Regards, Nick
Offline
Re: Have section list page show a single article?
Offline
Re: Have section list page show a single article?
Thank you again. Those were two issues that I always wanted but couldn’t figure out how to do.
Last edited by arellanon (2019-06-01 13:21:13)
Regards, Nick
Offline