Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-04-08 04:46:58

vineonardo
Member
Registered: 2011-08-31
Posts: 128
Website

[SOLVED] How do I Assign a picture to Category?

Hello,
I need to assign a picture to category which will represent the category’s type.
I need to achieve this , thus I’m looking to add picture to category.

Thanks for your time.

Last edited by vineonardo (2013-04-08 13:44:45)

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

#3 2013-04-08 06:18:43

vineonardo
Member
Registered: 2011-08-31
Posts: 128
Website

Re: [SOLVED] How do I Assign a picture to Category?

Thanks Jorge,
Simple solutions are the always the best.
I’ll give your trick a try. Will let you know how it goes.

Have a great day.

Offline

#4 2013-04-08 07:35:31

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

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

#5 2013-04-08 08:13:08

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

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

#6 2013-04-08 08:26:46

vineonardo
Member
Registered: 2011-08-31
Posts: 128
Website

Re: [SOLVED] How do I Assign a picture to Category?

Hello Oleg & Yiannis,
Thank you both for your answers, now adding images to categories looks really easy.

Offline

#7 2013-04-08 09:19:12

vineonardo
Member
Registered: 2011-08-31
Posts: 128
Website

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

#8 2013-04-08 13:35:24

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

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

#9 2013-04-08 13:44:14

vineonardo
Member
Registered: 2011-08-31
Posts: 128
Website

Re: [SOLVED] How do I Assign a picture to Category?

Thanks Colak,
I’ve not tried the plugin yet but I think I’ll go with your solution as it seems easier to me.

Thank you all.

Last edited by vineonardo (2013-04-08 13:45:10)

Offline

Board footer

Powered by FluxBB