Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-07-21 10:08:01

vadiuz
New Member
From: Russia
Registered: 2020-07-21
Posts: 2

[SOLVED] I think I found a bug in the article_custom tag

Hi.

Now I work om my first project on Tetxpattern CMS. And as it seems to me I found a incorrect working article_custom tag if the section name is set through a predefined variable.

The code above does not working correctly in any of two variation:

Variation 1. This does not work:

<txp:variable name="section_name" value="<txp:section />" />

<!-- Simple temporary probe for variable section_name -->

<br> ---<txp:variable name="section_name" />--- <br>
<br> ---'<txp:variable name="section_name" />'--- <br>
<br> ---"<txp:variable name='section_name' />"--- <br>

<!-- End of probe for variable section_name -->

<div class="col-md-6">
	<txp:article_custom limit="3" offset="3" section="<txp:variable name='section_name' />" sort="Posted desc">
		<txp:output_form form="fronpage_card" />
	</txp:article_custom>
</div>

But tag article_custom does not work in this configuration.

Browser outputs in this case:

---matters---
---'matters'---
---"matters"--- 

<div class="col-md-6">
</div>

Variation 2. And this case also does not work: (I’ve swapped the normal and single quotes around the variable expression.)

<txp:variable name="section_name" value="<txp:section />" />

<!-- Simple temporary probe for variable section_name -->

<br> ---<txp:variable name="section_name" />--- <br>
<br> ---'<txp:variable name="section_name" />'--- <br>
<br> ---"<txp:variable name='section_name' />"--- <br>

<!-- End of probe for variable section_name -->

<div class="col-md-6">
	<txp:article_custom limit="3" offset="3" section='<txp:variable name="section_name" />' sort="Posted desc">
		<txp:output_form form="fronpage_card" />
	</txp:article_custom>
</div>

But article_custom also does not too work in this variation.

Browser outputs in this case:

---matters---
---'matters'---
---"matters"--- 

<div class="col-md-6">
</div>

And at the same time, if the section name is assigned directly (not through a variable) with any quotes, the code works correctly:

<txp:variable name="section_name" value="<txp:section />" />

<!--    Var. 1: Single quotes    --> 
<div class="col-md-6">
	<txp:article_custom limit="3" offset="3" section='matters' sort="Posted desc">
		<txp:output_form form="fronpage_card" />
	</txp:article_custom>
</div>

<!--    Var. 2: Double quotes    --> 
<div class="col-md-6">
	<txp:article_custom limit="3" offset="3" section="matters" sort="Posted desc">
		<txp:output_form form="fronpage_card" />
	</txp:article_custom>
</div>

Browser outputs in both cases:

<!--    Var. 1: Single quotes    --> 
<div class="col-md-6">
	<div class="my_frontpage_card">
		<!-- Success Outputs of article -->
		...
		...
	</div>
	<div class="my_frontpage_card">
		<!-- Success Outputs of article -->
		...
		...
	</div>
</div>

<!--    Var. 2: Double quotes    --> 
<div class="col-md-6">
	<div class="my_frontpage_card">
		<!-- Success Outputs of article -->
		...
		...
	</div>
	<div class="my_frontpage_card">
		<!-- Success Outputs of article -->
		...
		...
	</div>
</div>

What can I do to get my code to work with my variable?

Thanks in advance.

Last edited by vadiuz (2020-07-21 11:23:43)

Offline

#2 2020-07-21 10:20:27

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: [SOLVED] I think I found a bug in the article_custom tag

Hello, welcome to the forum.

I think the problem comes from <txp:variable name="section_name" value="<txp:section />" />. It should be <txp:variable name="section_name" value='<txp:section />' />. It’s a bit counter-intuitive, but txp does not parse attributes inside double quotes.

Offline

#3 2020-07-21 10:21:52

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,529
Website GitHub Twitter

Re: [SOLVED] I think I found a bug in the article_custom tag

Hi vadiuz,

To make a tag in tag you must use simple quote not double quote :

<txp:variable name="section_name" value='<txp:section />' />

Same thing for other codes :

<div class="col-md-6">
	<txp:article_custom limit="3" offset="3" section='<txp:variable name="section_name" />' sort="Posted desc">
		<txp:output_form form="fronpage_card" />
	</txp:article_custom>
</div>

Hope that helps you.

Offline

#4 2020-07-21 11:19:44

vadiuz
New Member
From: Russia
Registered: 2020-07-21
Posts: 2

Re: [SOLVED] I think I found a bug in the article_custom tag

Hehe. Thank you, colleagues! I steamed longer and wrote the original post, at the same time mastering textile strongly (but no doubt such an experience will be useful). And helpful answers on my case I was catched in minutes. My code immediately worked in this case:

<txp:variable name="section_name" value='<txp:section />' />
...
<txp:article_custom limit="3" offset="3" section='<txp:variable name="section_name" />' sort="Posted desc">
...

Many thanks to everyone who answered for your tips! )
It’s even cooler than a neural network )

Last edited by vadiuz (2020-07-21 11:48:28)

Offline

#5 2020-07-21 12:40:25

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,529
Website GitHub Twitter

Re: [SOLVED] I think I found a bug in the article_custom tag

vadiuz wrote #324735:

It’s even cooler than a neural network )

it s a biological neural network ;)

Offline

Board footer

Powered by FluxBB