Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-10-22 17:27:49

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 572

[Solved] Display an image categories title

I know this should be easy but I’m having a mind freeze and what with impending deadlines (I wish to leave before 8:00pm tonight =P) I thought I’d ask here. I’m trying to get the following code working but keep getting tag errors.

<h1><txp:section title="1" /> <txp:images category='<txp:image_info type="category" />' limit="1"> - <txp:image_info type="category_title" /></txp:images></h1>

Tag error: <txp:image_info type="category" /> -> Textpattern Notice: Image tags cannot be used outside an image context on line 2344

Last edited by Algaris (2012-10-23 10:00:34)

Offline

#2 2012-10-22 17:57:08

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

Re: [Solved] Display an image categories title

Not sure what you’re trying to achieve with the tag-in-attribute. Essentially you’re asking Textpattern to plug in the value of <txp:image_info /> without telling it which image to get the info from.

The category attribute needs to be supplied either as:

  • A fixed value, like category="mountains"
  • A tag-in-tag from the surrounding context — outside the images tag you’re trying to plug the attribute into (e.g. the URL /category/mountains would plug “mountains” into the URL if used as: category='<txp:category />'. This could also be the image category in the URL if you add type="image" to the category tag)
  • A named image, by supplying the id or name attribute to the <txp:image_info /> tag (which could, of course, be pulled from the current article being displayed, e.g. from a custom field, although the quotes and apostrophes in the tag-in-attribute-in-tag would get interesting if you did this!)

Does that help at all and allow you to go home within the next hour and three minutes?

Last edited by Bloke (2012-10-22 18:02:59)


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

Online

#3 2012-10-23 08:15:05

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 572

Re: [Solved] Display an image categories title

Thanks for the reply Stef. I probably didn’t explain things as clearly I could have as I was in a rush.

I have an image gallery that displays a series of images from different categories. For the gallery title I’m using <txp:title /> and I’m trying to add the image categories title to the page as I would using <txp:catagory title="1" />. For some reason I can output the category but not the categories title. In a nutshell I’m after this:

Section Title - Image Category Title

I was trying to avoid using fixed values as I wanted each gallery to dynamically plug in its category title without having to hard code each one.

Last edited by Algaris (2012-10-23 10:00:16)

Offline

#4 2012-10-23 09:48:56

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

Re: [Solved] Display an image categories title

Algaris wrote:

Section Title - Image Category Title

If the category is in the URL, can’t you use:

<h1><txp:section title="1" /> - <txp:category title="1" type="image" /></h1>

?

Last edited by Bloke (2012-10-23 09:51:18)


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

Online

#5 2012-10-23 10:00:02

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 572

Re: [Solved] Display an image categories title

Thank you that did it. I told you it would be easy, I completely forgot about adding the category type last night.

Offline

Board footer

Powered by FluxBB