Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-02-13 15:00:11

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,492
Bitbucket GitHub

[SOLVED] article_custom and variable oddness

I’m working on some code to evaluate whether article_custom outputs anything, and do something if it does. If I use this code:

<txp:variable name="coupon_table_expiry_none" value='<txp:article_custom category='<txp:output_form form="coupon_table_sections_select" />' expired="0" form="coupon_table_expiry_none" limit="999" section="deals" sort="Expires asc" />' />
<txp:if_variable name="coupon_table_expiry_none" value="">
<txp:else />
There is stuff
</txp:if_variable>

The variable coupon_table_expiry_none evaluates to true and There is stuff is correctly output to the browser. I want to set up table, thead and tbody markup where There is stuff is, and that works out fine. I’m falling down when I try to use article_custom in place of There is stuff — a straight code switch:

<txp:variable name="coupon_table_expiry_none" value='<txp:article_custom category='<txp:output_form form="coupon_table_sections_select" />' expired="0" form="coupon_table_expiry_none" limit="999" section="deals" sort="Expires asc" />' />
<txp:if_variable name="coupon_table_expiry_none" value="">
<txp:else />
<txp:article_custom category='<txp:output_form form="coupon_table_sections_select" />' expired="0" form="coupon_table_expiry_none" limit="999" section="deals" sort="Expires asc" />
</txp:if_variable>

This outputs nothing. No debug errors. I’m at a loss as to figure out why.

As always, any and all assistance in gratefully appreciated (more than you know). Thank you in advance for any pointers.

Last edited by gaekwad (2013-02-13 16:11:59)

Offline

#2 2013-02-13 15:25:36

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

Re: [SOLVED] article_custom and variable oddness

Pete, take a look at Attribute value escaping. There is a small syntax error in the code related to quotes, but I will let you to do the thinking and learning instead of me giving the straight answers. I think you figuring it out on your own will help more in the long run.

Other tip I can give you is that, try to look for a way to reduce identical article queries, and the results sets where possible. If you have the list already stored in a variable, you can return that variable instead of querying the results again. Saves you valuable server resources.

Last edited by Gocom (2013-02-13 15:26:58)

Offline

#3 2013-02-13 15:30:53

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,492
Bitbucket GitHub

Re: [SOLVED] article_custom and variable oddness

Thank you, Jukka — you’ve been very helpful.

Offline

#4 2013-02-13 15:55:07

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,492
Bitbucket GitHub

Re: [SOLVED] article_custom and variable oddness

Gocom wrote:

There is a small syntax error in the code related to quotes, but I will let you to do the thinking and learning instead of me giving the straight answers.

Thank you for the pointer and the link, Jukka. I’ve revised the code to this:

<txp:variable name="coupon_table_expiry_none" value='<txp:article_custom category=''<txp:output_form form="coupon_table_sections_select" />'' expired="0" form="coupon_table_expiry_none" limit="999" section="deals" sort="Expires asc" />' />

…which seems to work.

Offline

#5 2013-02-13 16:06:21

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

Re: [SOLVED] article_custom and variable oddness

gaekwad wrote:

…which seems to work.

That’s it ;-) Alternatively, the variable tag specifically can be used as a container. E.g.

<txp:variable name="coupon_table_expiry_none"><txp:article_custom category='<txp:output_form form="coupon_table_sections_select" />' expired="0" form="coupon_table_expiry_none" limit="999" section="deals" sort="Expires asc" /></txp:variable>

Which avoid the need for escaping since the value isn’t used an attribute value.

Last edited by Gocom (2013-02-13 16:11:53)

Offline

#6 2013-02-13 16:11:12

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,492
Bitbucket GitHub

Re: [SOLVED] article_custom and variable oddness

/does the I fixed my problem dance around the office.

Offline

#7 2013-02-13 16:13:49

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

Re: [SOLVED] article_custom and variable oddness

gaekwad wrote:

/does the I fixed my problem dance around the office.

What I’m imagining.

Offline

#8 2013-02-13 16:29:14

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,492
Bitbucket GitHub

Re: [SOLVED] article_custom and variable oddness

Gocom wrote:

What I’m imagining.

After some over-exertion and air-punching, now I feel like the dude with the cup on the far right.

(The far right of the video, not the political spectrum.)

Offline

Board footer

Powered by FluxBB