Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
How do I display the image of a category?
I’m trying to do a movies section of my site, whereby the movies will be categorised by their ratings (ie: 5 stars, 4 stars, etc). Instead of displaying the names of the category (5 stars, for example), can I make it so that it will display the represented image instead? For instance, the category of 5 stars will display an IMAGE of 5 stars.. etc.
I’m wondering if this is possible with TXP, or should I look for plugins?
Offline
#2 2007-01-20 23:31:19
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do I display the image of a category?
Offline
Re: How do I display the image of a category?
Fantastic! Exactly what I’m looking for, thanks! :D
Offline
Re: How do I display the image of a category?
Somewhat related to the topic, for some reason, my category pages won’t display a listing of the names of the articles in the category concerned. :/ Do note that I haven’t used categories since I started my blog.. Even though I already have an article posted under the category ’3 stars’, said article does not appear: http://movies.saigoheiki.com/category/3-stars/
As a test, under the page template ‘default’, I have the following:
@<txp:if_category name=“3 stars”>
<txp:upm_category1_image width=“yes” height=“yes” wraptag=“none” />
<txp:recent_articles label=“3 stars” limit=“9999” break=“br” wraptag=“p” class=“list” category=“3 stars” />
<txp:article />
</txp:if_category>
<txp:if_individual_article>
<p class=“articlenav”>
<txp:link_to_prev><txp:prev_title /></txp:link_to_prev> <txp:link_to_next><txp:next_title /></txp:link_to_next></p>
</txp:if_individual_article>
<txp:if_article_list>
<p class=“paging”>
<txp:older>Previous</txp:older> <txp:newer>Next</txp:newer>
</p>
</txp:if_article_list>@
Is the code correct? In order to view the appropriate categories, I have to put it under the page template of ‘default’, right?
Last edited by Saigo (2007-01-21 04:59:51)
Offline
#5 2007-01-21 14:59:06
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do I display the image of a category?
Check if your spelling of the category name is correct. It has to be the name, not the title (in the if_category tag and the recent_articles tag).
Offline
Re: How do I display the image of a category?
Yeah, the spelling of the category name is indeed correct. :/
Offline
#7 2007-01-21 15:50:27
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: How do I display the image of a category?
I asked because I don’t think a category name can contain a space, like in ’3 stars’. It would probably be more like ’3-stars’. Did you check in Content > Categories and then click on the category? If it really is ’3 stars’ try changing this to ’3-stars’ and see if it works then.
Last edited by els (2007-01-21 15:52:06)
Offline
#8 2007-01-22 20:32:38
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How do I display the image of a category?
<txp:if_category name="3 stars">
<txp:upm_category1_image...
You’re using the wrong tag. :)
Offline
Re: How do I display the image of a category?
*blink* Which tag am I using wrongly? I looked through the upm_category1_image plugin help file again and it seems right.. kindly enlighten this code-illiterate soul. =P
Last edited by Saigo (2007-01-23 18:51:37)
Offline
#10 2007-01-23 21:11:54
- anoke
- Archived Plugin Author
- Registered: 2006-04-15
- Posts: 152
Re: How do I display the image of a category?
upm_category1_image works only in article form. upm_category_image works in page. I think that’s what Mary was saying.
<txp:if_category name="3 stars">
<txp:upm_category_image...
<txp:if_individual_article>...
<txp:if_article_category name="3 stars">
<txp:upm_category1_image...
I’d check also against to cat1 or cat2 in if_article_category because now you might get mixed results if you’re using both categories.. (“3 stars” in cat2 would trigger cat1 image…?)
You might do with TXP’s own stuff with ‘fixed’ set of categories (but Mary’s plugin rawks with unfingercountable cats..) like
<txp:if_individual_article>
<txp:if_article_category name="1 stars">
<txp:image id="*some id*"/>
</txp:if_article_category>
<txp:if_article_category name="2 stars">
<txp:image id="*some other id*"/>
</txp:if_article_category>
....
or so. But as Els suggested do check those category names.
- When chickens are cold, they roost in trees; when ducks are cold, they plunge into water -
Offline
Re: How do I display the image of a category?
Thanks a lot anoke, but sorry for the very late reply.
Here’s what I have for my page called “list” (the content part, at least):
<ul>
<txp:article_custom limit=99999 form="movies_alphabetical" />
<txp:if_individual_article>
<txp:if_article_category name="1-star">
<txp:image id="2"/>
</txp:if_article_category>
<txp:if_article_category name="15-stars">
<txp:image id="3"/>
</txp:if_article_category>
<txp:if_article_category name="2-stars">
<txp:image id="4"/>
</txp:if_article_category>
<txp:if_article_category name="25-stars">
<txp:image id="5"/>
</txp:if_article_category>
<txp:if_article_category name="3-stars">
<txp:image id="6"/>
</txp:if_article_category>
<txp:if_article_category name="35-stars">
<txp:image id="7"/>
</txp:if_article_category>
<txp:if_article_category name="4-stars">
<txp:image id="8"/>
</txp:if_article_category>
<txp:if_article_category name="45-stars">
<txp:image id="9"/>
</txp:if_article_category>
<txp:if_article_category name="5-stars">
<txp:image id="10"/>
</txp:if_article_category>
</txp:if_individual_article>
</ul>
Again, my “movies_alphabetical” form page is:
<txp:if_different><h3><txp:php>echo substr(title(array()), 0, 1);</txp:php></h3></txp:if_different>
<li><txp:permlink><txp:title /></txp:permlink></li>
When a tag trace is done, everything seems fine except for the following:
<txp:if_individual_article>
[<txp:if_individual_article>: false]
</txp:if_individual_article>
Why would it be false? >_<
Offline
#12 2007-02-03 09:14:15
- anoke
- Archived Plugin Author
- Registered: 2006-04-15
- Posts: 152
Re: How do I display the image of a category?
Because you aren’t viewing an individual article there – you are viewing article list. Invidiual article means that there is ID or article title in the current URL.
BTW; <txp:if_ article _category> is used in article form, you should use <txp:if_category> when in list. If you’d move that long <txp:if_article_category> part after </if_different> into “movies_alphabetical” article form, it should work then.
I didn’t know if_different catches PHP :O Third time this day, I really have to keep my eyes better open..
- When chickens are cold, they roost in trees; when ducks are cold, they plunge into water -
Offline