Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Offline
#2 2013-04-08 06:09:57
- milosevic
- Member
- From: Madrid, Spain
- Registered: 2005-09-19
- Posts: 390
Re: [SOLVED] How do I Assign a picture to Category?
You can do it vía category names, naming pictures equal than the category you want to illustrate. That allow you to retrieve the image vía CSS or HTML:
Img/<txp:category/>.jpg
.category-name{ backround-image:url(img/category-name.jpg)}
Perhaps there are other better ways but without plugins I think this is the simplest one.
<txp:rocks/>
Offline
Offline
Re: [SOLVED] How do I Assign a picture to Category?
You could also create corresponding image categories and use <txp:images /> tag. Both solutions are error-prone, but there is no “inter-type” categories in Textpattern.
Offline
Re: [SOLVED] How do I Assign a picture to Category?
Another way us to create images with their name being the same as that of the category.
So the resulting code would be <txp:image name='<txp:category />' />
> Edited to add that care should be taken so as not to have 2 images with the same name
Last edited by colak (2013-04-08 08:28:27)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Offline
Re: [SOLVED] How do I Assign a picture to Category?
Hello All,
I found this plugin by Mary, seems like a solution to my problem.
Plugin link
Also found this tip on Txptips.
Last edited by vineonardo (2013-04-08 09:21:05)
Offline
Re: [SOLVED] How do I Assign a picture to Category?
I wouldn’t go the plugin way as much as I fully respect Mary’s work.
If you want the category image to appear only when you are in a category listing page you can easilly achieve this using native tags.
<txp:variable name="categoryname" value='<txp:page_url type="c" />' />
<txp:if_variable name="categoryname" value="">
<txp:else />
<txp:image name='<txp:category />' />
</txp:if_variable>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Offline