Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#169 2008-11-19 11:46:07
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Hoi Bloke,
Your idea isn’t working properly.
Page 1 is displayed well.
Page 2 is blank.
This is my page template :
<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“eq,undefined” value=“2005-04”>
<txp:article limit=“1” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
<txp:else />
<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“eq,eq” value=“2005-04, 1”>
<txp:article limit=“1” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
<txp:else />
<txp:smd_if field=“urlvar:month” operator=“eq” value=“2005-04>
<txp:article limit=“3” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
</txp:smd_if>
</txp:smd_if>
</txp:smd_if>
And this is the tag trace :
<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“eq,undefined” value=“2005-04”>
[<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“eq,undefined” value=“2005-04”>: false]
<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“eq,eq” value=“2005-04, 1”>
[<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“eq,eq” value=“2005-04, 1”>: false]
<txp:article limit=“3” form=“dagboek” sort=“Posted asc” />
[SQL (0,000254154205322): select name from txp_section where on_frontpage != ‘1’]
[SQL (0,000365972518921): select count(*) from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = 0) and (Category1 IN (‘zwangerschap’) or Category2 IN (‘zwangerschap’)) and Posted like ’2005-04%’ and Section != ‘about’ and Section != ‘contact’ and Section != ‘gallery’]
[SQL (0,00075888633728): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = 0) and (Category1 IN (‘zwangerschap’) or Category2 IN (‘zwangerschap’)) and Posted like ’2005-04%’ and Section != ‘about’ and Section != ‘contact’ and Section != ‘gallery’ order by Posted asc limit 3, 3]
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
</txp:smd_if>
</txp:smd_if>
As far i can see the right article form is working nl 3 articles a page but on the page i see nothing.
Roelof
Offline
#170 2008-11-19 11:57:18
Re: smd_if: Generic multiple if condition tests
roelof wrote:
Your idea isn’t working properly.
Are you sure? Pay attention to the details and try adding the missing quote around the value
in the following line:
<txp:smd_if field="urlvar:month" operator="eq" value="2005-04>
Then see what you get back.
(Edit: could you try and add bc.
in front of your code blocks in future posts please, it’s quite hard to trace it when it’s one continuous stream of stuff on the screen, thanks!)
Last edited by Bloke (2008-11-19 11:58:25)
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
#171 2008-11-19 12:13:30
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Hello Bloke,
Still the same.
Here a new tagtrace :
<txp:smd_if field="urlvar:month, urlvar:pg" operator="eq,undefined" value="2005-04">
[<txp:smd_if field="urlvar:month, urlvar:pg" operator="eq,undefined" value="2005-04">: false]
<txp:smd_if field="urlvar:month, urlvar:pg" operator="eq,eq" value="2005-04, 1">
[<txp:smd_if field="urlvar:month, urlvar:pg" operator="eq,eq" value="2005-04, 1">: false]
<txp:smd_if field="urlvar:month" operator="eq" value="2005-04">
[<txp:smd_if field="urlvar:month" operator="eq" value="2005-04">: true]
<txp:article limit="3" form="dagboek" sort="Posted asc" />
[SQL (0,000200986862183): select name from txp_section where on_frontpage != '1']
[SQL (0,000367879867554): select count(*) from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = 0) and (Category1 IN ('zwangerschap') or Category2 IN ('zwangerschap')) and Posted like '2005-04%' and Section != 'about' and Section != 'contact' and Section != 'gallery']
[SQL (0,000756025314331): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from textpattern where 1=1 and Status = 4 and Posted <= now() and (now() <= Expires or Expires = 0) and (Category1 IN ('zwangerschap') or Category2 IN ('zwangerschap')) and Posted like '2005-04%' and Section != 'about' and Section != 'contact' and Section != 'gallery' order by Posted asc limit 3, 3]
<txp:ob1_pagination outputlastfirst ="0" outputnextprevious="0" />
</txp:smd_if>
</txp:smd_if>
</txp:smd_if>
Roelof
Offline
#172 2008-11-19 12:47:20
Re: smd_if: Generic multiple if condition tests
roelof wrote:
Still the same.
Hmm, very odd. As you can see from the tag trace, the smd_if is executing correctly:
- first test is [false] (i.e.
pg
is defined) - 2nd test is false (i.e.
pg
is not 1) - 3rd test [true] (i.e.
month
is 2005-04).
Then you can see that the article tag is called, executes 3 queries and then ob1_pagination is called.
So as far as smd_if is concerned, it is actually doing everything correctly but for some (other) reason, your article tag and/or ob1_pagination are returning nothing. Weird. It’s kind of out of my league here since it could be any number of things: articles not set to display in that section; not enough articles to display; articles with wrong dates; some random error in your form; …
Sorry, you’ve reached the end of my knowledge I think. Has anyone else got any pearls of wisdom?
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
#173 2008-11-19 12:53:38
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Hai Bloke,
Can it be that for some reasons txp starts the queries on the 3 article.
I.m thinkig yes because the limit shows [3.3] and then txp finds nothing because there are 3 articles now for testing reasons.
Roelof
Offline
#174 2008-11-19 12:56:32
Re: smd_if: Generic multiple if condition tests
roelof wrote:
Can it be that for some reasons txp starts the queries on the 3 article.
I wondered about that 3, 3 thing too. So it’s starting at the 3rd article (I assume because we’re on page 3?) and you have set a limit of 3 articles to display. If there are only 3 articles in total, then that would explain it!
Last edited by Bloke (2008-11-19 12:57:02)
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
#175 2008-11-19 13:00:52
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Oke,
I found the solution.
If a do this <txp:article limit=“3” form=“dagboek” offset=”-2” sort=“Posted asc” /> then 2 articles are displayed.
On some way txp starts counting wrong.
Roelof
Offline
#176 2008-11-20 09:07:52
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Hai Bloke,
Still some problems with the use of this plugin.
My page template is like this :
<div id="content">
<txp:if_section name=",default">
<txp:if_category name="zwangerschap,jaar1,jaar2,jaar3,jaar4">
<txp:smd_if field="urlvar:month" operator="eq" value="2005-04">
<txp:smd_if field="urlvar:pg" operator="ge" value="2">
<txp:article limit="2" form="dagboek" sort="Posted asc" />
<txp:ob1_pagination outputlastfirst ="0" outputnextprevious="0" />
<txp:else />
<txp:article limit="1" form="dagboek" sort="Posted asc" />
<txp:ob1_pagination outputlastfirst ="0" outputnextprevious="0" maximumtabs="4"/>
</txp:smd_if>
<txp:else />
<txp:smd_if field="urlvar:month" operator="defined">
<txp:article limit="5" form="dagboek" sort="Posted asc" />
</smd_if>
</smd_if>
<txp:else />
<txp:article_custom section="voorpagina" form="default" />
</txp:if_category>
</txp:if_section>
</div>
But now it’s schows nothing at all.
Txp stops at the <div id= “content”>
Do you have any clue why ?
Roelof
Offline
#177 2008-11-20 09:38:07
Re: smd_if: Generic multiple if condition tests
roelof wrote:
</smd_if>
Details again: should be </txp:smd_if>
(x2).
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
#178 2008-11-20 16:39:57
Re: smd_if: Generic multiple if condition tests
I have a site which will, over time, accumulate multiple articles of the same name (different url-only title) — short bios with where the title is the person’s name. In the search results, if that person’s name is searched on, I’d like to return only the most recent of those articles. I feel like this plugin is the way there…but not sure how. Or maybe there is a simpler way?
Any help appreciated.
Offline
#179 2008-11-20 17:42:47
Re: smd_if: Generic multiple if condition tests
nabrown78 wrote:
I have a site which will, over time, accumulate multiple articles of the same name (different url-only title) — short bios with where the title is the person’s name. In the search results, if that person’s name is searched on, I’d like to return only the most recent of those articles. I feel like this plugin is the way there…but not sure how. Or maybe there is a simpler way?
Could you clarify your requirements? You need only sorting search results by date, when newest articles are the first in list?
Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?
Offline
#180 2008-11-20 17:58:52
Re: smd_if: Generic multiple if condition tests
Hi Victor -
Let’s say I have two biographic articles about Joe Schmoe, and three biographic articles about Joe Plumber. If someone does a search for “Joe” I want to display only the most recent article about Joe Schmoe, and only the most recent article about Joe Plumber. Does that make sense? At the moment I can’t see a straightforward way to achieve it.
Offline