Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2009-03-11 01:05:19

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Come on, make if_data core

pish posh. including an if_data tag is the more elegant and encompassing of the solutions – if_variable seems hackish in comparison. and I totally agree…it seems odd to bother with if_article_image – rather than covering all the scenarios with if_data.

as mrdale so eloquently wrote

It kinda opens the door to all kinds of silliness; if_body, if_sitename, if_filename, if_donkeys_sit_on_my_head, if_I_were_a_rich_man

word Dale. word.

:)

Last edited by renobird (2009-03-11 01:06:29)

Offline

#17 2009-03-11 09:37:00

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Come on, make if_data core

I’ve used chh_if_data a couple of times with great success. However, it counts whitespace as “data” so I created a tweaked version to get around this.

I’d be interested to see whether <txp:if_variable name="hasdata" value=""> would work in the presence of whitespace.

Offline

#18 2009-03-11 11:15:42

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

Re: Come on, make if_data core

renobird wrote:

pish posh. including an if_data tag is the more elegant and encompassing of the solutions – if_variable seems hackish in comparison. and I totally agree…it seems odd to bother with if_article_image – rather than covering all the scenarios with if_data.

Well, if_data sounds great but it isn’t the all-around friend:

  • It makes pages slower because it blindly parses the tag, when specific conditional tag just simply does fast check, not a parse-it-all.
  • Multi-tag-support.
  • if_variable covers those both: you can specify what the man uses to check the condition (but still is slower than real conditional tag), and you can use it with multiple tags.

if_data is a powerful tool which makes it neat. Thus, if you need it, you can use the plugin and not to use in build conditionals. If_data is good as a plugin.

Offline

#19 2009-03-11 17:27:37

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Come on, make if_data core

Still haven’t heard a compelling argument why we should have a specific tag to test for output from another specific tag while, a generalized tag is considered cruft, but I guess I don’t have to, I’m just someone who builds a lot of sites with this thing.

Offline

#20 2009-03-16 16:53:05

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Come on, make if_data core

Bump, So er… wet, rudd.

How about making this core to replace the more specific and less versatile if_article_image?

Twice (or more) as nice…

Last edited by mrdale (2009-03-16 17:09:00)

Offline

#21 2009-03-16 19:56:27

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

Re: Come on, make if_data core

mrdale wrote:

Bump, So er… wet, rudd.

How about making this core to replace the more specific and less versatile if_article_image?

Twice (or more) as nice…

Still, you sometimes will want to use the tag and conditional seperately, plus if_data is slower to parse than optimized conditional tag.

Remember, if you need it, it’s there as a plugin.

Last edited by Gocom (2009-03-16 19:57:07)

Offline

#22 2009-03-16 20:09:30

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Come on, make if_data core

Gocom wrote:

Still, you sometimes will want to use the tag and conditional seperately, plus if_data is slower to parse than optimized conditional tag.

Remember, if you need it, it’s there as a plugin.

Quite right. But to be clear I think if we’re adding tags (if_article_image) we should add ones that have more function to more people, In this case a tag that would serve both purposes gracefully.

Offline

#23 2009-03-25 18:32:17

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: Come on, make if_data core

I’d be very interested in something like this. Right now I have:

<div class="imgInfo"><cite><txp:upm_img_alt /></cite>, <txp:upm_img_caption /></div>

but, unfortunately a couple of my images don’t have captions, only alts – and in that case I don’t want the comma. If I could output the comma only if there is a caption, that’d be swell, and it seems like <txp:if_data> would do the trick.

Offline

#24 2009-03-25 18:35:43

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Come on, make if_data core

nabrown78 wrote:

that’d be swell, and it seems like <txp:if_data> would do the trick.

chh_if_data is your friend, just have to load it. My point is, that this is basic, and versatile enough to be core.

Last edited by mrdale (2009-03-25 18:36:49)

Offline

#25 2009-03-25 20:07:13

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

Re: Come on, make if_data core

Yes, I know I’m repeating myself :)

<txp:variable name="if_caption" value='<txp:upm_img_caption />' />

<div class="imgInfo"><cite><txp:upm_img_alt /></cite><txp:if_variable name="if_caption" value=""><txp:else />, <txp:upm_img_caption /></txp:if_variable></div>

Offline

#26 2009-03-25 20:24:03

renobird
Member
From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786
Website

Re: Come on, make if_data core

Forgive me Els – :)

chh_if_data version
<div class="imgInfo"><cite><txp:upm_img_alt /></cite><txp:chh_if_data>, <txp:upm_img_caption /></txp:chh_if_data></div>

vs.

if_variable version
<txp:variable name="if_caption" value='<txp:upm_img_caption />' />

<div class="imgInfo"><cite><txp:upm_img_alt /></cite><txp:if_variable name="if_caption" value=""><txp:else />, <txp:upm_img_caption /></txp:if_variable></div>

Seems to me that chh_if_data would take this round.

:)


T

Last edited by renobird (2009-03-25 20:24:38)

Offline

#27 2009-03-25 22:55:35

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Come on, make if_data core

Bing! Yep I beleive no-one has a problem with using if variable per-se.

It’s just a big, ugly chunk of code to use in numerous places on your site. And no-one has yet addressed the issue of precedent. That is, if we add an ulra-specific tag like if_article_image why not add a tag that is actually 900 times more useful and can still handle the initial problem? But I’m officially out of breath, here.

I’ll continue to install chh_if_data till it doesn’t work, then I’ll use twice the code with the ugly hack that uses the if_variable tag. YAY!

Last edited by mrdale (2009-03-25 22:57:22)

Offline

#28 2009-03-25 23:47:53

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

Re: Come on, make if_data core

renobird wrote:

Forgive me Els – :)

Of course :) I just love the variable and if_variable tags so much that I can’t stop talking about them… ;)

Offline

Board footer

Powered by FluxBB