Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-07-19 09:28:40

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

category image

hi!

can i somehow associate image with category? like i can article through article image field.
i would like to create category list with images, similar to article list. impossible?

Offline

#2 2022-07-19 09:32:16

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,468
Website GitHub

Re: category image

If you define an Image Category tree then yes. You can associate any uploaded image with a category. And then use <txp:category_list type="image" /> to show them.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2022-07-19 10:41:53

Gallex
Member
Registered: 2006-10-08
Posts: 1,308

Re: category image

Bloke wrote #333720:

If you define an Image Category tree then yes. You can associate any uploaded image with a category. And then use <txp:category_list type="image" /> to show them.

brilliant! will try soon

Offline

#4 2022-07-20 23:58:39

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 99

Re: category image

If I needed to generate a list of linked article categories with an image associated with each category, and the client needed to be able to edit, I might try one of these to connect an image to an article category:

  • set up image categories matching the article categories and assign one image to each then call using something like <txp:category_list><txp:permlink><txp:images category="<txp:category />" limit="1"><txp:image /> etc
  • or name an image with the same name as a category and call it up with name="<txp:category />.jpg"
  • or use jcr_image_custom to add an extra field to the image panel, where the client can add the article category id or name.

Offline

#5 2022-07-21 05:23:35

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

Re: category image

peterj wrote #333725:

If I needed to generate a list of linked article categories with an image associated with each category, and the client needed to be able to edit, I might try one of these to connect an image to an article category:

  • set up image categories matching the article categories and assign one image to each then call using something like <txp:category_list><txp:permlink><txp:images category="<txp:category />" limit="1"><txp:image /> etc
  • or name an image with the same name as a category and call it up with name="<txp:category />.jpg"
  • or use jcr_image_custom to add an extra field to the image panel, where the client can add the article category id or name.

Or you can create a new image category, say mix_categories, add images there, and then use the name field of the images to link to the categories.

<txp:images category="mix_categories" limit="99" wraptag="div" break="" class="mix_categories">
<a href="<txp:image_info type="name" />"><txp:image /></a>
</txp:images>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

Board footer

Powered by FluxBB