Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-06-29 09:30:10

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

<txp:if_image_info /> tag possibility?

Haven’t thought this through totally myself, but wonder if there is a possibility of a <txp:if_image_info /> tag nested within a <txp:images /> tag in the future, like so…

<txp:if_image_info type="caption"><figcaption><txp:image_info type="caption" /></figcaption></txp:if_image_info>

Or another usage…

<txp:if_image_info type="category" value=""><p>Uncategorised</p></txp:if_image_info>

Offline

#2 2011-06-29 22:26:54

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

Re: <txp:if_image_info /> tag possibility?

Why create new conditional tags if it can be done with variable/if_variable?

Offline

#3 2011-06-30 08:11:18

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: <txp:if_image_info /> tag possibility?

Oh, of course, I said I had not thought this through too much! We can use…

<txp:variable name="if_caption" value="<txp:image_info type='caption' />" />
<txp:if_variable name="if_caption" value="">
  <txp:else />
  <figcaption><txp:image_info type='caption' /></figcaption>
<txp:if_variable>

Although we can just use <txp:image_info /> without the type, as caption is the default – I’ve just put that in there to make it easier to understand.

Thanks.

Last edited by philwareham (2011-06-30 08:24:08)

Offline

#4 2011-06-30 08:15:51

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: <txp:if_image_info /> tag possibility?

philwareham wrote:

Oh, of course, I said I had not thought this through too much! We can use…

Exactly, just flip the quotes (straight quotes surrounding the attribute values containing tags), and you can also use the variable itself to return the value, like so:

<txp:variable name="caption" value='<txp:image_info type="caption" />' />
<txp:if_variable name="caption" value="">
<txp:else />
	<figcaption><txp:variable name="caption" /></figcaption>
<txp:if_variable>

:)

Offline

#5 2011-06-30 08:26:48

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: <txp:if_image_info /> tag possibility?

I always get the quotes mixed up first time, shortest method then is…

<txp:variable name="caption" value="<txp:image_info />" />
<txp:if_variable name="caption" value="">
<txp:else />
  <figcaption><txp:image_info /></figcaption>
</txp:if_variable>

Last edited by philwareham (2011-07-03 15:39:00)

Offline

#6 2011-06-30 22:41:07

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

Re: <txp:if_image_info /> tag possibility?

Offline

Board footer

Powered by FluxBB