Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2010-01-04 20:00:02
- Bongo-man
- Member
- Registered: 2009-03-18
- Posts: 243
Article link listing byCategory matching section name of listing page
I would like to improve the performance on my TXP installation and reduce the code lenght, by listing different articles in different index pages, without making use of conditional expressions.
So I was wondering wether it could work an expression like this:
<txp:article_custom category=”<section />” label=“List label:” sort=“Posted desc” wraptag=“p” break=br limit=“10”>
<txp:permlink><txp:title /></txp:permlink> – <i>Publishing date:</i> <txp:posted wraptag=“em” />
</txp:article_custom>
Where section is the section of each listing page, whose name I would take care it match with second category name of the listed articles .
What I’m not sure is that of category=”<section />” .
I’ve read the <txp:section /> returns the section name that in this case could match one of the 2 article category names.
Thanks in advance for the eventual answers
Offline
#2 2010-01-04 20:34:12
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Article link listing byCategory matching section name of listing page
<txp:section />
returns the name of the section that is currently being viewed.
If you are using a tag as an attribute’s value, you need to use single quotes (see Textbook: Parsing Tag Attributes):
<txp:article_custom category='<section />' label="List label:" sort="Posted desc" wraptag="p" break="br" limit="10">
<txp:permlink><txp:title /></txp:permlink> - <i>Publishing date:</i> <txp:posted wraptag="em" />
</txp:article_custom>
So on a section page for section ‘cats’ this could would display a list of articles in category ‘cats’. Is that what you had in mind?
Last edited by els (2010-01-04 20:34:42)
Offline
#3 2010-01-04 20:48:17
- Bongo-man
- Member
- Registered: 2009-03-18
- Posts: 243
Re: Article link listing byCategory matching section name of listing page
YES
…BUT REALLY, afterwards I noticed, my problem is a little more complex: I need a selection of article links, in each listing page, based on both the article categories, but I see only <txp:article /> allow to use this more complex sorting procedure.
But <txp:article /> does not allow me to list article links, but only articles.
For this reason time ago I used succesfully a more complex expression, but now I’m afraid for the DB performance.
Can I nestle two <txp:article_custom /> ? …. like this way:
<txp:article_custom category=’<section />’ />
<txp:article_custom category=‘group1’ label=“List label:” sort=“Posted desc” wraptag=“p” break=“br” limit=“10”>
<txp:permlink><txp:title /></txp:permlink> – <i>Publishing date:</i> <txp:posted wraptag=“em” />
</txp:article_custom>
</txp:article_custom>
<txp:article_custom category=’<section />’ />
<txp:article_custom category=‘group2’ label=“List label:” sort=“Posted desc” wraptag=“p” break=“br” limit=“10”>
<txp:permlink><txp:title /></txp:permlink> – <i>Publishing date:</i> <txp:posted wraptag=“em” />
</txp:article_custom>
</txp:article_custom>
and so on?
In the case it works, could it be better than two nestled conditional expressions?
So my questions could be also:
Is better (about the DB performance) to use a conditional expression and a sorting attribute (of a nestled tag), or two nestled conditional expression, or two sorting attributes for a tag, without any condition?
Is a long list of categories, in a conditional expression, well managed by the DB, if I indicate it, before, the section in which those categorized articles are listed, …or the DB could prefer to read only a long list of categories to verify if they match with the condition?
THANKS
Last edited by Bongo-man (2010-01-04 21:15:56)
Offline
#4 2010-01-04 21:31:15
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Article link listing byCategory matching section name of listing page
I don’t think that is possible (without having tested it), because article_custom is context insensitive I suspect that the second tag won’t look at the category attribute set in the first tag…
You could do this though:
<txp:article_custom category='<section />' label="List label:" sort="Posted desc" wraptag="p" break="br" limit="10">
<txp:if_artice_category name="group1">
<txp:permlink><txp:title /></txp:permlink> - <i>Publishing date:</i> <txp:posted wraptag="em" />
</txp:if_article_category>
</txp:article_custom>
I assume that this will influence performance in some way (depending on the number of articles you have), because the tag still has to go through all articles to find the ones in the right category.
An alternative would be smd_query, it offers a lot more possibilities for querying the DB. Though I still don’t know which method will put the least load on it (but if you decide to have a look at smd_query I’m sure Stef will be able to tell you).
Offline
#5 2010-01-04 22:47:06
- Bongo-man
- Member
- Registered: 2009-03-18
- Posts: 243
Re: Article link listing byCategory matching section name of listing page
I’m thinking I will not change this template (perhaps something other).
Because at now TXP select with <txp_if_section /> among 11 section/listing pages and print various permalink articles from some specific article categories, different in the different listing pages by means of <txp_article_custom /> .
I think this could be better than <if_category /> because when TXP finds each category, he print (In my site) some permalinks.
Perhaps I’m thinking .. what could affect more the DB are the if-queries for listed articles, than the one to identify a listing page. Isn’t it
…As soon as possible I will also look at SMD_query.
Thank you very much,
Last edited by Bongo-man (2010-01-04 23:22:46)
Offline