Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2018-05-23 19:57:59
- Dylan
- New Member
- Registered: 2018-05-23
- Posts: 5
Customize article-list output?
Hi all,
I’m new to textpattern (used for a day, love it so far).
I’m just wondering whether it is possible to modify the output of article-list? I can see from the PHP side I have <txp:article class=“article-list” form=“article_listing” limit=“10” wraptag=“ul” /> and this is outputted as article title, posted date, author, etc. Is it possible to omit author and date from the output? I can’t see how to do it anywhere.
Dylan
Offline
Re: Customize article-list output?
Hi Dylan and welcome,
Have a look at the form called article_listing
. That defines how the article is actually output. You can change that (or perhaps better, duplicate and rename it), then play around with the tags in it. Change the attribute to form="your_form_name"
and you’ll see your changes.
TXP Builders – finely-crafted code, design and txp
Offline
#3 2018-05-23 20:02:07
- Dylan
- New Member
- Registered: 2018-05-23
- Posts: 5
Re: Customize article-list output?
I will try that!
Thanks very much jakob.
Dylan
Offline
#4 2018-05-23 20:13:46
- Dylan
- New Member
- Registered: 2018-05-23
- Posts: 5
Re: Customize article-list output?
Hmmmm… I’m still struggling to get this to work. I’m not sure what I’m doing wrong.
Offline
Offline
#6 2018-05-23 21:07:08
- Dylan
- New Member
- Registered: 2018-05-23
- Posts: 5
Re: Customize article-list output?
To be honest, I have no idea what I’m doing, how to combine the code to get it to just display a list of articles but remove the author and time :/
Offline
#7 2018-05-23 21:25:42
- Dylan
- New Member
- Registered: 2018-05-23
- Posts: 5
Re: Customize article-list output?
I’m looking through article lists here:http://txptag.org/txp/article_custom
All I see is how to change the returned items based on queries, but nothing about hiding certain parts (such as timestamp).
Offline
Re: Customize article-list output?
Okay, a quick primer:
- When an article tag is encountered, Textpattern looks at the URL.
- It says to itself: is this URL an individual article or is it a landing page (article list)?
- If it’s an individual article, it goes and fetches the article and displays it. It does this by calling the
Form
calledarticle_listing
because your tag tells it to. That Form has a bunch of tags in it that output various article-related content, such as the body text (<txp:body />
), the date the article was written (<txp:posted />
) and so forth. - If Textpattern determines it needs to display an article list, it calls the same Form in this case but it will only display a cut-down version of the content. Same idea though: the tags output snippets of content from each article in turn. So for the first article it might output the title, the excerpt, the author, the date posted. Then the next article it’d output the title, excerpt, author, date posted, and so forth until it reaches 10 (as defined by the
limit
attribute in your article tag).
So the key, as jakob says, is in your article_listing
Form. Visit Presentation->Forms, click the article_listing entry and look at the code. It’ll probably contain a block somewhere that reads either:
<txp:if_individual_article>
// Some tags here to output stuff if Textpattern is viewing an article
<txp:else />
// Some tags here to output stuff for each article in a list
</txp:if_individual_article>
or:
<txp:if_article_list>
// Some tags here to output stuff for each article in a list
<txp:else />
// Some tags here to output stuff if Textpattern is viewing an article
</txp:if_article_list>
Either way, Textpattern makes a decision via the ‘if’ tags right there. It only executes one of the blocks of code depending on whether it’s displaying a “list” or an “individual article”. So inside the relevant block is where you’ll find the tags that output your various article components. Tinker with those. Even type in some random text and save the Form, then refresh your site page. You’ll see those words pop up. That’s when you know you’ve found the right part of the right Form!
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
#9 2018-05-23 21:56:08
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,305
Re: Customize article-list output?
Dylan wrote #312033:
To be honest, I have no idea what I’m doing, how to combine the code to get it to just display a list of articles but remove the author and time :/
Hi Dylan! Jakob means: Go to the admin side, there Presentation > Forms. There you’ll find a link to a form named article_listing
. Click it, then duplicate it (link top right). That step creates a form named article_listing_copy
. Edit that form to your desire (look for the <txp:posted />
and the <txp:author />
tag, or — probably better — delete the <p class="footnote">
, the whole tag soup from there to the bottom, but leave the final </li/>
tag). Click save.
Then go back to the page where you have your article tag you put in your first posting here. Alter the contents of the form
attribute to article_listing_copy
and click save.
Edit: Ah, Bloke was faster.
Last edited by uli (2018-05-23 21:57:29)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Pages: 1