Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-05-02 17:08:35
- ede
- Member
- Registered: 2006-05-02
- Posts: 39
Get category of current article
hi,
is it possible to find out the category of an article by a tag?
i think of something like this:
<code>
<div class=“teaser”>
<txp:article_custom section=“teaser” limit=“2” sortby=“Posted” sortdir=“desc” listform=“teaser” category=“here is the tag that gives me the category of the article” />
</div>
</code>
i want to show an article and an individual infobox on the articledetailpage
Offline
#2 2006-05-02 18:01:46
- KurtRaschke
- Plugin Author
- Registered: 2004-05-16
- Posts: 275
Re: Get category of current article
So this would be called from within an article form? I don’t know if that will work at all; seems to me that there could be problems with the $thisarticle
global getting trampled, but, in the event that the code would allow it, then the following might work:
<div class="teaser">
<txp:php>
echo article_custom(array(
"section"=>"teaser",
"limit"=>"2",
"sortby"=>"Posted",
"sortdir"=>"desc",
"listform"=>"teaser",
"category"=>$GLOBALS['thisarticle']['Category1']));
</txp:php>
</div>
-Kurt
kurt@kurtraschke.com
Offline
#3 2006-05-03 05:35:51
- ede
- Member
- Registered: 2006-05-02
- Posts: 39
Re: Get category of current article
thank you kurt,
at this point i don’t need a form so i put your code directly in my pagetemplate.
but it doesn’t work: i get all infoboxes/articles with section ‘teaser’ – the filter by category seems to have no effect.
Offline
#4 2006-05-03 18:28:20
- KurtRaschke
- Plugin Author
- Registered: 2004-05-16
- Posts: 275
Re: Get category of current article
Aah…that’s a different case then. Try this:
<div class="teaser">
<txp:php>
echo article_custom(array(
"section"=>"teaser",
"limit"=>"2",
"sortby"=>"Posted",
"sortdir"=>"desc",
"listform"=>"teaser",
"category"=>$GLOBALS['pretext']['c']));
</txp:php>
</div>
-Kurt
kurt@kurtraschke.com
Offline
#5 2006-05-04 07:54:09
- ede
- Member
- Registered: 2006-05-02
- Posts: 39
Re: Get category of current article
yeah, thanks again – it works!
but there’s a (little?) problem remaining.
first i try to explain my project:
on the left side of the page i will show the maintext of one article at a time which is assigned to the section “dev” (mainnavigation). other articles which are also assigned to “dev” are categorized in one category (cat1, cat2, cat3, …).
these categories are shown on the right side of the page as a “subnavigation” (with help of the plugin “cbs_category_list”). under this subnavigation the individual teaser/infobox should appear.
and now the problem:
when you click on “dev” in the mainnavigation (http://localhost/tvr/dev) no category(subnavigationitem) is selected yet, but i want to start with an introtext which has also it’s own teaser/infobox.
<code>
<div id=“content”>
<txp:article form=“detail” limit=“1” sortdir=“asc” />
</div>
<div id=“sidebar”>
<h2>Subnavigation:</h2>
with this strategy the “introarticle” must also be categorized (maybe to “introtext” – it would be perfect if this category is not shown in my subnavigationlist).
my method of resolution was this:
<code>
<div id=“sidebar”>
<h2>Subnavigation:</h2>
<txp:cbs_category_list wraptag=“ul” break=“li” activeclass=“active” />
<txp:if_article_category name=“here must be something like: no category selected or category =introtext”>
<txp:article_custom section=“teaser” category=“introtext” limit=“2” sortby=“Posted” sortdir=“desc” listform=“teaser” />
<txp:else />
<div class=“teaser”> <txp:php> echo article_custom(array( “section”=>“teaser”, “limit”=>“2”, “sortby”=>“Posted”, “sortdir”=>“desc”, “listform”=>“teaser”, “category”=>$GLOBALS[‘pretext’][‘c’])); </txp:php> </div> </div> </code>Last edited by ede (2006-05-04 07:55:36)
Offline
Pages: 1