Textpattern CMS support forum

You are not logged in. Register | Login | Help

#151 2008-11-15 15:47:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,778
Website

Re: smd_if: Generic multiple if condition tests

roelof wrote:

If month=2005-04 and there’s no page (http://test2.tamarawobben.nl/?c=zwangerschap&month=2005-04) then show one article.
and after that i want if month=2005-04 and page=2 then show 3 articles.

Then you’ll need something like:

<txp:smd_if field="urlvar:month, urlvar:pg" operator="eq,undefined" value="2005-04">
 // Show one article here
<txp:else />
  // Show 3 articles here
</txp:smd_if>

EDIT: but also remember that the ‘else’ will be executed if the month variable is something other than 2005-04

Last edited by Bloke (2008-11-15 15:55:04)


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

#152 2008-11-15 18:01:08

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,202
Website

Re: smd_if: Generic multiple if condition tests

OK, this is interesting….

I routinely use mdp_calendar to build cals on installs…

One of the problems I have is that a link from a small calendar will lead to a date based url. I have not found a way to gracefully distinguish between a single article and an article list (one event that day or two.) So that if it’s a single article it displays <txp:body/> and if it’s a list display <txp:excerpt/>.

The best I’ve come up with is to always display the first article in full and thereafter as excerpts.

Any other Text-Fu? Come on chumpus, go purple.

Offline

#153 2008-11-15 19:03:31

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

Re: smd_if: Generic multiple if condition tests

oke,

If i understand it right :

if month=“2004-05” and pg is not defined or pg=1

i do this :

<txp:smd_if field=“urlvar:month, urlvar:pg, urlvar:pg” operator=“eq,undefined,eq” logic=“and”,“or” value=“2005-04”,“1”>

Roelof

Offline

#154 2008-11-15 19:26:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,778
Website

Re: smd_if: Generic multiple if condition tests

roelof wrote:

<txp:smd_if field=“urlvar:month, urlvar:pg, urlvar:pg” operator=“eq,undefined,eq” logic=“and”,“or” value=“2005-04”,“1”>

Nope. You can only do one type of logic at a time, sorry. You have to choose either AND (the default) or logic="or" to switch it. I did consider allowing multiple logic types (see an earlier post by the_ghost) but it was very complicated and I abandoned the idea. Especially since nested smd_if calls are going to be allowed in TXP 4.0.7.

Under TXP 4.0.6, what you are trying to do is pretty tricky and I can’t think of a way of doing it without resorting to some <txp:php> inside the <txp:smd_if> tag.

mrdale

Interesting indeed, but bad news for you as well: I can’t find a variable anywhere on the page that would allow me to test that condition. If it ain’t on the page, I can’t check it :-(

I wondered if $thispage had anything useful (like, if the calendar used it to store the total number of results that matched the current date) but for some reason I can’t even display the contents of it on my SVN test site; I just get back NULL all the time. Clearly I don’t understand what it does, despite trying this! I’ll delve a bit deeper, but at the moment it’s no no mojo from the chumpstick right now.

Last edited by Bloke (2008-11-15 19:27:35)


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

#155 2008-11-15 20:05:29

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,202
Website

Re: smd_if: Generic multiple if condition tests

chumperoo> Thanks. You are a man among chumps, indeed.

Offline

#156 2008-11-15 20:45:12

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

Re: smd_if: Generic multiple if condition tests

Hello Bloke,

Thank you for your time.
If this is not possible it no big deal.

Roelof

Offline

#157 2008-11-15 23:24:51

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: smd_if: Generic multiple if condition tests

(Stef, sorry for abusing your plugin thread, but) Roelof, if all you need to do is check if it’s the first page or not, wouldn’t wet_if_page be a better and simpler way to do that?

Offline

#158 2008-11-16 11:40:08

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

Re: smd_if: Generic multiple if condition tests

Hello Els,

I have to check if the month is 2005-04 and if it’s then i have to check if it’s the first page of that month.

Roelof

Offline

#159 2008-11-16 11:50:47

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,778
Website

Re: smd_if: Generic multiple if condition tests

Els is right (thank you). You can do what you ask, like this:

<txp:smd_if field="urlvar:month, urlvar:pg" operator="eq,undefined" value="2005-04">
  // Show one article here
<txp:else />
  <txp:wet_if_page page="1">
    // Show one article here also
  <txp:else />
    // Show 3 articles here
  </txp:wet_if_page>
</txp:smd_if>

i.e. if the month is 2005-04 and the pg is not used, you must be on the front page, thus you show one article. If, however, the page is used you enter the ‘else’ block whereby it checks to see if the page is page nmuber 1. If it is, you only show one article, if it’s not you show 3.

Thanks again Els. Nice one!


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

#160 2008-11-16 14:51:16

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

Re: smd_if: Generic multiple if condition tests

Hai Bloke,

Your script works only i have 3 remarks.

1) The other months shows now the first article double.

2) Ob-pagination thinks on the first page that there are 5 pages and on the second page there are two pages.

3) The month 2005-04 has 7 articles nl. 1,4,5,7,11,15,24 april When using this script on page 1 i see 1 april , that’s correct. But on page 2 i see 7 and 15 april. The rest of the articles seem tot be disappear.

You can see it work at : http://test2.tamarawobben.nl

Regards,

Roelof

Last edited by roelof (2008-11-16 14:56:34)

Offline

Board footer

Powered by FluxBB