Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-10-11 11:42:16
- majkinetor
- Member
- Registered: 2007-10-10
- Posts: 13
How to display articles of the same category as currently displayed.
In my setup, there is 1 section and N categories. Each category contains 1 sticky article and X live articles and they are all part of the same section.
I want to achieve this effect:
1. display all sticky articles in the section (there is only 1 sticky per category, kind of category home page)
2. when user clicks on article I want to show that article and show the menu with all other articles in that category (they are all ‘live’), then to go to those articles when user clicks on them
So, it looks like this:
MySecttion
|
|- Category 1 --- Category home page ( sticky )
| Categor menu ( titles of live articles )
|
|
|- Category 2 --- .....
Currently, I succeded in step 1 and to show sticky article from step 2, but not in creating the menu of other articles in that category.
This is the page of MySection
<txp:if_individual_article>
<txp:article form="article" status="5"/>
<txp:else />
<txp:article_custom form="article_overview" section="MySection" status="5" />
</txp:if_individual_article>
and in article
form which just displays entire article, I added on top:
<txp:article_custom form="article_titles" status="4" category="<txp:category/>" />
as you can’t use txp tag inside other tag (which I found out later)
I can’t hardcode category as I want same behavior for all other categories.
How can I solve this
thx.
Offline
Re: How to display articles of the same category as currently displayed.
chh_article_custom might be of help as it takes a wildcard attribute to display all articles of the current category.
majkinetor wrote:
as you can’t use txp tag inside other tag (which I found out later)
also: asy_wondertag
Last edited by sthmtc (2007-10-11 12:23:16)
Offline
#3 2007-10-11 12:35:10
- majkinetor
- Member
- Registered: 2007-10-10
- Posts: 13
Re: How to display articles of the same category as currently displayed.
I am checking the things you posted, sound like they will do the job for me.
Is it really not possible to do it without plugins ? Sounds like common scenario.
I read here that if_different can be used to dump articles by the common value (here by category), but I failed to see how/if it can be used here.
Thx.
Offline
Re: How to display articles of the same category as currently displayed.
Unless I’m mistaken many of the default tags don’t have the option to have values set to ‘current’. For example, if I am looking at a page in category X I would like to be able to have that value pass to a tag. This is particularly useful for conditional tags.
cch_article_custom allows this. eg: category=”?”
Last edited by lozmatic (2007-10-11 13:16:12)
Offline
Re: How to display articles of the same category as currently displayed.
Unless I’m mistaken many of the default tags don’t have the option to have values set to ‘current’
True, but you can sometimes achieve this by feeding back a ‘current’ variable (e.g. txp:section or txp:cateogry) into a tag. Because of the problem of putting tags inside other tags, you have to call the txp function written out in php, or use txp:asy_wondertag.
TXP Builders – finely-crafted code, design and txp
Offline
#6 2007-10-11 14:26:26
- majkinetor
- Member
- Registered: 2007-10-10
- Posts: 13
Re: How to display articles of the same category as currently displayed.
I realised that but I definitely need more explanation about how txp engine works…..
First, I don’t know why can’t I put section’s page template simple like this:
<txp:if_article_list>
<txp:chh_article_custom status="4" form="article_title" />
</txp:if_article_list>
<txp:if_individual_article>
<txp:chh_article_custom category="?" status="4" form="article_title" />
<txp:article form="article" status="5"/>
</txp:if_individual_article>
I get here bunch of errorrs “Unknown tag attribute” ??? Speaking about this, I wonder why I can’t put something like
<txp:if_individual_article>
<txp:title>
</txp:if_individual_article>
when Textpattern book says that I can use article tags in if_individual_article
. Perhaps somebody can put a light on this, especialy as article tag ouputs form within this very same “if” tag. I also don’t understand why specifying <txp:id>
works there, and <txp:title>
doesn’t …
The next thing i did was to return page template to its old setup:
<txp:if_article_list>
<txp:article_custom status="5" form="article_overview" />
</txp:if_article_list>
<txp:if_individual_article>
<txp:article form="article" status="5"/>
</txp:if_individual_article>
and change the article form article
to add menu there
<txp:article_custom form="article_title" status="4" />
<h2><txp:title /></h2>
<txp:body />
</div>
This worked here except it listed from all categories which is the place when I could use chh tag to add category=”?”. However, when in above code i just replace article_custom with chh_article_custom and don’t change anything else, I get bunch of errors:
tag_error <txp:title/> -> Textpattern Notice: Article tags cannot be used outside an article context on line 1887
tag_error <txp:body/> -> Textpattern Notice: Article tags cannot be used outside an article context on line 1887
....
I wonder how can that happen, by just adding @chh_@ infront of @article@.
asy_wondertag works:
<txp:asy_wondertag>
<txp:article_custom form=“article_title” status=“4” category=”<txp:category1/>” />
</txp:asy_wondertag>
Last edited by majkinetor (2007-10-11 14:30:24)
Offline
Re: How to display articles of the same category as currently displayed.
The errors are not displayed if you change the Production Status to a ‘live’ .
Offline
#8 2007-10-11 15:03:56
- majkinetor
- Member
- Registered: 2007-10-10
- Posts: 13
Re: How to display articles of the same category as currently displayed.
I know, but it doesn’t solve the problem.
Anyway, the only thing left for me to do now to finish this setup is to change sections page. It is currently defined as:
<txp:if_article_list>
<txp:article_custom status="5" form="article_overview" />
</txp:if_article_list>
<txp:if_individual_article>
<txp:article form="article" status="5"/>
</txp:if_individual_article>
So, at start I have list of ‘stickie’ articles, then i click one , then I go to it and menu with ‘live’ article titles is there (this menu is created in the form) and then I need to display article which is clicked using that menu. As it is not sticky , above code displays empty pages.
I supossed there is somtehing like if_article_status status="live"
but that doesn’t exist. Also I can’t use asy_wondertag to put status of clicked artickle instead hardcoded 5 as there is, again, no such thing as <txp:article_status/>
.
So what to do here?
Offline
Re: How to display articles of the same category as currently displayed.
Is it really a problem? Are the errors generated because one hasn’t defined all the attributes in the tag?
Offline
#10 2007-10-11 18:55:43
- majkinetor
- Member
- Registered: 2007-10-10
- Posts: 13
Re: How to display articles of the same category as currently displayed.
No, the errors are also generated for attributes I set. Its not a problem but that must mean something.
Last edited by majkinetor (2007-10-11 20:05:41)
Offline
Re: How to display articles of the same category as currently displayed.
Have you tried this?
<txp:if_article_list>
<txp:article_custom status="5" form="article_overview" />
<txp:else />
<txp:article form="article" status="5" />
<txp:article form="article" status="4" />
</txp:if_article_list>
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: How to display articles of the same category as currently displayed.
majkinetor wrote:
I get here bunch of errorrs “Unknown tag attribute” ??? Speaking about this, I wonder why I can’t put something like
<txp:if_individual_article>
<txp:title>
</txp:if_individual_article>
You have a typo there, and I think it breaks all the TxP parser.
<txp:title>
(and any other single tag) should be self-closed: <txp:title />
and change the article form
article
to add menu there
<txp:article_custom form="article_title" status="4" />
<h2><txp:title /></h2>
<txp:body />
</div>
The above code doesn’t make too much sense for me…
Offline