Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-07-01 17:38:39

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

I've already used double quotes and single quotes. Now what?

I am collecting a bunch of individual articles into a variable:

<txp:variable name="featured-events" value='<txp:article_custom time="future" Featured="_%" section="Events,fundraisers,Films,performing-arts" break=","><txp:article_id /></txp:article_custom>'/>

… then I’m combining a bunch of similar queries into a bit list:

<txp:variable name="articles" value='<txp:variable name="featured-events"/>,<txp:variable name="featured-non-events"/>,<txp:variable name="blog"/>,<txp:variable name="future-exhibition"/>,<txp:variable name="current-exhibition"/>' />

… then I want to see if at least one of those articles has a custom field set and use that to control the flow:

<txp:variable name="featured-high" value='<txp:article_custom id="<variable name='articles' />" Featured="High" />' />
<txp:if_variable name="featured-high" value=""><txp:else />
<txp:variable name="featured-high" />
</txp:if_variable>

My problem is in that first line, whereI’m using double quotes inside single quotes and I need another ‘level’ of quotation. What’s the solution, some sort of escaping with backslashes? HTML quote characters?


Yes, I have tried turning it off and on.

Offline

#2 2016-07-01 18:00:09

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: I've already used double quotes and single quotes. Now what?

You should use txp:variable as a container tag to avoid this kind of problem.
If you provide a clean and readable code, I’d be glad to help more.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#3 2016-07-01 18:07:56

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: I've already used double quotes and single quotes. Now what?

Hi alesh

here you have

<txp:variable name="featured-high" value='<txp:article_custom id="<variable name='articles' />" Featured="High" />' />
<txp:if_variable name="featured-high" value=""><txp:else />
<txp:variable name="featured-high" />
</txp:if_variable>

it should be:

<txp:variable name="featured-high" value='<txp:article_custom id='<txp:variable name="articles" /> Featured="High" />' />
<txp:if_variable name="featured-high" value="">
<txp:else />
<txp:variable name="featured-high" />
</txp:if_variable>

notice the single quotes around the id attribute.

>Edited to add

I take it that you have a custom field named Featured?
What kind of info do you add to it?

>Edit 2
Good catch Nicolas. corrected above

Last edited by colak (2016-07-01 18:16:53)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2016-07-01 18:13:22

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: I've already used double quotes and single quotes. Now what?

I didn’t know the <variable /> tag… ;-)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#5 2016-07-01 18:29:42

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: I've already used double quotes and single quotes. Now what?

It still won’t work; look at your value:

value='<txp:article_custom id='<txp:variable name="articles" /> Featured="High" />'

I can’t understand that… 3 simple quotes?

Last edited by NicolasGraph (2016-07-01 18:35:52)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#6 2016-07-01 18:44:59

alesh
Member
From: Miami, FL
Registered: 2005-04-13
Posts: 228
Website

Re: I've already used double quotes and single quotes. Now what?

colak wrote #300116:

I take it that you have a custom field named Featured?
What kind of info do you add to it?

I’m using glz_custom_fields. Featured can be set to “High”, “Medium”, “Low” or be blank. Articles from some sections get on the homepage regardless of featured, from other sections only if they’re featured, and from other sections only if they’re featured and the date is before/after the current date. The featured setting is used to sort, with some overrides for certain sections. It’s all quite a mess, and the result eventually will be a self-updating home page where everything is in it’s right place at all times.

I think Nicholas is correct that using <txp:variable> as a container tag is what will bail me out. I’m saving this for Monday morning in hopes that my brain will be working then.


Yes, I have tried turning it off and on.

Offline

#7 2016-07-01 22:33:54

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,595
Website

Re: I've already used double quotes and single quotes. Now what?

Make it easier for yourself and use the outer txp:variable as a container tag. Then you only need to include the inner txp:variable in the normal way as a tag-in-tag attribute without any double nesting. Note: you forgot the txp: in the inner variable:

<txp:variable name="featured-high"><txp:article_custom id='<txp:variable name="articles" />' Featured="High" /></txp:variable>

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB