Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-04-14 14:52:06

manastojones
Member
Registered: 2009-04-13
Posts: 14

Help with image_display and image_index tags...

Hi. Just started using Textpattern, but I have a pretty good understanding of how other CMS’s work (I think), just having a few problems with the image-display and the image-index tags.

I would like to display a group of images associated with an article in a sidebar only when the images exist. I know that I have figured out a way to do this with a combination of custom_field tags and image categories, but I haven’t figured out how to get the images to load or why they are not. Here is my sidebar code:

<txp:if_individual_article>
<txp:if_custom_field name="Image Gallery">
<div class="article-images">
	<txp:image_index c="<txp:custom_field name="Image Gallery" />" wraptag="ul" break="li" />
	<txp:image_display />
</div>
</txp:if_custom_field>
</txp:if_individual_article>

Basically, the custom_field “Image Gallery” is also the name of an image category, and if it is set, I assume it would call all the images associated with it and display them (if I am using the code right, or even the right tags). But here is how it finally renders in the source:

<div class="article-images"> 
	<txp:image_index c="sam-fuller" wraptag="ul" break="li" /> 
</div>

So… I definitely know that I am doing something wrong, but I just don’t know what, because it looks like the engine is just passing right over the image_index tag.

From what I’ve read, it seems like these tags, if they are placed inside an article tag (which they are, in my case), automatically fetch the category of the current article (which, for me, in this instance, is “Movies”) instead of any category you specify, but I don’t understand why you can pass the category parameter (c="sam-fuller", or c="<txp:custom_field name="Image Gallery" />" dynamically) if it is just going to override it from the article.

I’m getting this information for the tags from the TXP Tag Reference book here.

Does this make any sense? Am I not using the tags right, or are the other tags I should be using?

Thanks in advance!

Last edited by manastojones (2009-04-14 14:54:20)

Offline

#2 2009-04-14 15:05:34

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

Re: Help with image_display and image_index tags...

manastojones wrote:

Am I not using the tags right, or are the other tags I should be using?

I’ve never had much luck with image_index and image_display but I never really persevered cos I wrote a pluign to do it instead!

But in this case it may simply be a quoting issue. In order for the parser to parse tags-in-tags you should surround the c attribute with single quotes like this:

<txp:image_index c='<txp:custom_field name="Image Gallery" />' wraptag="ul" break="li" />

That way, the parser doesn’t get confused with the double quotes in the inner tag. Try that and see if it helps.


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 2009-04-14 15:09:45

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Help with image_display and image_index tags...

Try changing the quotes:

<txp:image_index c='<txp:custom_field name="Image Gallery" />' wraptag="ul" break="li" />

(TextBook: Parsing Tag Attributes)

(edit: bah… late… ;) )

Last edited by els (2009-04-14 15:10:21)

Offline

#4 2009-04-14 15:20:45

manastojones
Member
Registered: 2009-04-13
Posts: 14

Re: Help with image_display and image_index tags...

Freaking Bingo-Crepescule! It worked!

If there’s one thing I will never understand, it’s single vs double quotes.

Thanks a ton!

Offline

Board footer

Powered by FluxBB