Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-09-09 11:33:02

dorka
Member
Registered: 2012-10-04
Posts: 90

How to exclude image from article images list based on category?

Hi, I create a catalogue of fabrics. Each item is an article with set of images. The first image is the image of the presented item, the following images in the image field are images of other fabrics from the catalogue which go together well with the first one. E.g. one image appears in several articles and is manually placed in the articles’ image list by my client. The problem is: in case certain item is not available any more, how to hide its image from all articles in one step? Obviously hiding the article itself will not do.
I tried to make use of image categories: I assumed that if my client put the image itself in a separate image category (e.g. hidden) I could hide it by assigning proper css style. For this I need to output the category name and assign it as a class to all images. But the class attribute won’t parse txp tag. I studied this article http://textpattern.com/weblog/318/tag-parser-part-1 and applied the tag accordingly, but no class value appears in the resulting code of the page. Any Ideas please?

Last edited by dorka (2013-09-09 11:34:25)

Offline

#2 2013-09-09 11:43:15

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: How to exclude image from article images list based on category?

Please post your code, dorka.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2013-09-09 13:35:03

dorka
Member
Registered: 2012-10-04
Posts: 90

Re: How to exclude image from article images list based on category?

<txp:images limit="100" offset="1" wraptag="ul" class="fabric-gallery" break="li" >
<txp:thumbnail class='<txp:image_info type="category" />' />
</txp:images>

{Added Textile’s bc. for having straight quotes. – Uli}

Last edited by uli (2013-09-09 14:56:58)

Offline

#4 2013-09-09 15:03:45

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: How to exclude image from article images list based on category?

This snippet looks OK and is correctly quoted, so should actually output the class. (I assume you made sure the right category is existing and assigned to an image, and that the offset="1" didn’t swallow the correct image.)

Can you explain a little further what exactly you mean with this:

But the class attribute won’t parse txp tag.

Is the category tag still in the HTML source code? Is there no output where you expected the category? Is there no thumbnail displayed at all?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2013-09-10 04:06:36

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to exclude image from article images list based on category?

Your code has to be inside an article tag. Then, I would like to change it a little:

<txp:if_article_image>
	<txp:images sort='field(id, <txp:custom_field name="article_image" />)' thumbnail="1" wraptag="ul" class="fabric-gallery" break="li">
		<txp:thumbnail class='<txp:image_info type="category" />' />
	</txp:images>
</txp:if_article_image>

So you don’t need the offset attribute. The first image ID in the article image field will be the first image in the list.

And by the way: If you delete an image in the image data base, then nothing is shown in the articles source code, even if the ID is listed in the article image field.

Offline

#6 2013-09-10 09:59:56

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,304

Re: How to exclude image from article images list based on category?

dorka wrote:

Any Ideas please?

You’re using these tags in an article’s body field, right? I just had a similar effect to what you described. Set the “Article markup” menu to “Leave text untouched” or, if you can’t, put a notextile. in front of your code and delimit it from the following text with an empty line.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#7 2013-09-10 11:32:14

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to exclude image from article images list based on category?

You’re using these tags in an article’s body field, right?

Why? For me, this don’t make sense.

Offline

#8 2013-09-10 14:34:59

dorka
Member
Registered: 2012-10-04
Posts: 90

Re: How to exclude image from article images list based on category?

Hi there, ??. You’re using these tags in an article’s body field, right? ??
1. Actually I’m not. I’m using it in a form.
I was a little confused for a while, because I only realized now, that the piece of code I sent above renders properly. The problem comes when I try to add another class to the same element:
<txp:thumbnail class=‘slider <txp:image_info type=“category” />’ />
or <txp:thumbnail class=“slider ‘<txp:image_info type=“category” />’” />
the html output is:
bc. <img src=“http://dorastamenova.com/salonpodjabloni/images/157t.jpg” alt=”“ title=“Taft barvy petrol 037” width=“180” height=“240” *style=“border: 0px;”*> p.
In both cases!
I need another class because I need to resize the image. Maybe there is a better way t do this?

2. I need the offset for a separate reason – i show the first image in a separate box and than make a gallery from the rest of the images, so that they can be displayed next to the first one and be compared.
3. I do have the quoted tag inside an article tag.

Last edited by dorka (2013-09-10 14:37:46)

Offline

#9 2013-09-10 14:55:10

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to exclude image from article images list based on category?

Please, can you use Textile for quotes (bq. ) and codes (bc. ).

Last edited by GugUser (2013-09-10 14:55:27)

Offline

#10 2013-09-10 15:01:26

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to exclude image from article images list based on category?

Your example …

<txp:thumbnail class=“slider ‘<txp:image_info type=“category” />’” />

… should be …

<txp:thumbnail class='slider <txp:image_info type="category" />' />

Offline

#11 2013-09-10 15:22:02

dorka
Member
Registered: 2012-10-04
Posts: 90

Re: How to exclude image from article images list based on category?

Nope! Doesn’t work.

Offline

#12 2013-09-10 15:30:34

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: How to exclude image from article images list based on category?

What doens’t work?

For me, inside an article tag it works. For a test I put it temporally here. You can look the source code and you will see classes with “blabla” and the image categories.

It would be better, if you show us your complete code.

Last edited by GugUser (2013-09-10 15:43:46)

Offline

Board footer

Powered by FluxBB