Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#289 2010-02-19 08:31:59

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Bloke,

I have this code:


<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >
		<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>
			<txp:variable name="pagenumber" value='<txp:variable name="firstpage"/> '/>
		</txp:smd_if>
		<txp:smd_if field="my_custom_field_pagenr operator="ge" value='<txp:variable="lastpage">'/>
			<txp:variable name="pagenumber" value='<txp:variable name="lastpage"/>'/>
		</smd_if>
		<a href="?c=<txp:page_url type="c" />&month=<txp:page_url type="month" />&pg=<txp:variable name="pagenumber" />"><txp:custom_field name="pagenr"/></a>
		&nbsp;</li>
	<txp:else />
	<a href="?c=<txp:page_url type="c" />&month=<txp:page_url type="month" />&pg=<txp:page_url type="pg" />"><txp:custom_field name="pagenr"/></a></li>
	</txp:smd_if>

the first smd_if works fine.
When the totpages is 17 it true.
Then the current page (custom field pagenr) is 11 then firstpage will be 6.
The second smd-if is then false.
But the thirht smd-if (<txp:smd_if field=“my_custom_field_pagenr operator=“ge” value=’<txp:variable=“lastpage”> is never carried out.

Can you tell me why this happens ?

Roelof

Last edited by roelof (2010-02-19 08:33:16)

Offline

#290 2010-02-19 08:45:46

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: smd_if: Generic multiple if condition tests

Not sure if related, but you have a </smd_if> on your code, when it should be </txp:smd_if>.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#291 2010-02-19 09:06:34

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Manique.

I changed it but it seems not related.
I still get this tagtrace :

<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >
						[<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >: true]
						<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>
							[attribute 'value']
							<txp:variable name="firstpage"/>
							[/attribute]
							[<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>: false]
						</txp:smd_if>
						<txp:variable name="pagenumber" value='<txp:variable name="lastpage"/>'/>
							[attribute 'value']
							<txp:variable name="lastpage"/>
							[/attribute]
					</txp:smd_if>

Roelof

Offline

#292 2010-02-19 09:13:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: smd_if: Generic multiple if condition tests

roelof

Try adding the name attribute to your txp:variable in the 3rd smd_if tag.

<txp:smd_if field="my_custom_field_pagenr" operator="ge" value='<txp:variable name="lastpage">'/>

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#293 2010-02-19 09:25:23

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Bloke,

When I changed it to :L

<txp:smd_if field="my_custom_field_pagenr operator="ge" value='<txp:variable name="lastpage"/>'/>

I get this tag trace :

<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >
						[<txp:smd_if field="txpvar:totpages" operator="ge" value="11" >: true]
						<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>
							[attribute 'value']
							<txp:variable name="firstpage"/>
							[/attribute]
							[<txp:smd_if field="my_custom_field_pagenr" operator="le" value='<txp:variable name="firstpage"/>'>: false]
						</txp:smd_if>
						<txp:variable name="lastpage"/>
						<txp:variable name="pagenumber" value='<txp:variable name="lastpage"/>'/>
							[attribute 'value']
							<txp:variable name="lastpage"/>
							[/attribute]
					</txp:smd_if>

Roelof

Offline

#294 2010-02-19 09:39:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: smd_if: Generic multiple if condition tests

roelof

Keep an eye on the details. Did you also add the missing close quote on the smd_if’s field attribute? That might help :-)

Last edited by Bloke (2010-02-19 09:40:29)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#295 2010-02-19 13:09:59

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Oke,

That part work now.
But one problem left.
Why the script takes the <a href> after the else and not the <a href> after the smd-if for last page.

Roelof

Offline

#296 2010-02-19 13:32:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: smd_if: Generic multiple if condition tests

roelof wrote:

Why the script takes the <a href> after the else and not the <a href> after the smd-if for last page.

Perhaps because your 3rd smd_if is also self-closing: smd_if can only be used as a container tag. I think your closing / on that line should be for the txp:variable tag, and hence inside the tag inside the apostrophes.

Last edited by Bloke (2010-02-19 13:34:22)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#297 2010-02-19 13:45:09

roelof
Member
Registered: 2005-03-27
Posts: 647

Re: smd_if: Generic multiple if condition tests

Hello Bloke,

I think that’s how it supposed to be.
The first smd_if is the container for the other two.
So if the total pages are bigger then 11 then I check if the pagenumber is smaller then the firstpage so that’s numbers are not displayed. Then i check if the pagenumber is bigger then the lastpage so that numbers are not displayed. Then I make the url for the pages.
else so there are lesser pages then 11 then the normal url can be maded.

Roelof

Offline

#298 2010-02-19 13:49:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: smd_if: Generic multiple if condition tests

roelof wrote:

I think that’s how it supposed to be.

This line:

<txp:smd_if field="my_custom_field_pagenr" operator="ge" value='<txp:variable name="lastpage">'/>

Is syntactically incorrect. The closing / is currently part of the smd_if tag. It should be the closing slash of the txp:variable tag because that currently does not have one. Thus the parser will get confused.

Just move the slash back a couple of characters and it should help.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#299 2010-02-19 15:58:52

mlarino
Member
Registered: 2007-06-29
Posts: 367

Re: smd_if: Generic multiple if condition tests

Cant get this to work:

<txp:variable name="numresults">
<txp:smd_query query="SELECT count(*) as cantidad FROM textpattern  WHERE Section LIKE '%?opcion%' AND custom_1 LIKE '%?tipo%' " >{cantidad}</txp:smd_query>
</txp:variable>

<txp:smd_if field="txpvar:numresults" operator="gt" value="0" >
<txp:variable name="<txp:variable name="numresults" />" /> houses in NY, <a href="/results-page">see all <txp:variable name="numresultados" /></a>

<txp:else />

We are sorry, there was no results.

</txp:smd_if>

Offline

#300 2010-02-19 16:10:28

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,436
Website GitHub

Re: smd_if: Generic multiple if condition tests

mlarino

Couple of things to try:

  1. Remove the line breaks around your <txp:variable> container so that the smd_query is assigned to the variable without any rogue newlines or <br /> tags in it
  2. Fix the variable definition to take account of the nested attributes, e.g.
<txp:variable name='<txp:variable name="numresults" />' /> houses in NY, <a href="/results-page">see all <txp:variable name="numresultados" /></a>

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB