Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#136 2008-11-08 23:18:30
Re: smd_if: Generic multiple if condition tests
maniqui wrote:
it’s always returning “No caption. And this should also be emtpy = thecaption”, even when the image has a caption.
Weird, it works on my test page using smd_if v0.74. If you put debug="1" (or 2) on, do you get any indication why it might be failing the tests?
I have, however, uncovered a bug when using it this way round. For some reason, I have not escaped bad chars like apostrophes (stupid mistake I’ll have to hunt down) so if you have any apostrophes or other deal-breaking characters in your captions, the test will fail. In site debugging mode you’ll see a horrible error message. I will fix that.
By the way, this didn’t work either: <txp:smd_if field=”{title}” operator=“isempty”>…
No, sadly it won’t. The plugin will just cry if it sees an empty title. This is a known limitation and is documented.
Supports most major article, file, image and link variables
Ah, yes, that last one won’t work (yet) either because true image support isn’t built into the core yet. Remember my image patch I’m slowly refining? smd_if has jumped the gun and knows about the $thisimage variable (ruud has indicated it will likely become a reserved variable at some stage in the product).
Put simply, inside a hypothetical image_list tag in a future version of TXP, you could test the caption on your default ‘images’ form as it rendered each matching image. Sadly, none of that functionality exists right now so your last example is looking at the article for a field called ‘caption’ (which doesn’t exist) so the test fails.
I’m curious about the reason your NULL example doesn’t work, though. If you have any more info that might help me track it down I’d appreciate it.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#137 2008-11-09 15:15:39
Re: smd_if: Generic multiple if condition tests
Bloke wrote:
I have, however, uncovered a bug when using it this way round. For some reason, I have not escaped bad chars like apostrophes (stupid mistake I’ll have to hunt down) so if you have any apostrophes or other deal-breaking characters in your captions, the test will fail.
Voilà! The caption had some double quotes and that was the problem. Sorry for not have testing further to arrive to this conclusion by myself.
me: By the way, this didn’t work either: <txp:smd_if field=”{title}” operator=“isempty”>…
No, sadly it won’t. The plugin will just cry if it sees an empty title. This is a known limitation and is documented.
Yes, I forgot to say “as documented”. :)
I usually RTFM, even in your plugins where help are like a Bible :D.
Funny documentation btw.
I’m curious about the reason your NULL example doesn’t work, though. If you have any more info that might help me track it down I’d appreciate it.
As said above, the double quotes didn’t have mercy with your plugins. By the way, I’m also processing the caption with upm_textile so textile can be used on captions. But I think that isn’t related to our problem at all. Or may be?
This is the form as I’m using it now:
<txp:smd_if field="NULL" operator="not" value="{title}">
<div class="panel-column text-column">
<div class="panel-text">
<txp:upm_textile>{title}</txp:upm_textile>
</div><!-- .panel-text -->
</div><!-- .text-column -->
</txp:smd_if>
Offline
#138 2008-11-14 14:35:37
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Hello,
I was wonderig if this can work
<smd_if field=month operator=eq value=“2005-04, 2005-05”>
<txp:article limit=“1” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
<else>
<txp:article limit=“5” form=“dagboek” sort=“Posted asc” />
< /smd_if>
Regards,
Roelof
Offline
#139 2008-11-14 14:46:36
Re: smd_if: Generic multiple if condition tests
roelof wrote:
I was wonderig if this can work <snip>
To achieve what, exactly?
If you wish to check if the ?month variable in the URL is either 2005-04 or 2005-05 then you would need this:
<txp:smd_if field="urlvar:month, urlvar:month" operator="eq, eq" value="2005-04, 2005-05" logic="or">
<txp:article limit="1" form="dagboek" sort="Posted asc" />
<txp:ob1_pagination outputlastfirst ="0" outputnextprevious="0" />
<txp:else>
<txp:article limit="5" form="dagboek" sort="Posted asc" />
</txp:smd_if>
Otherwise, I’m not quite sure what it is you are trying to do. Please elaborate if that is not it.
EDIT: or use the new in operator like this:
<txp:smd_if field="urlvar:month" operator="in" value="2005-04/2005-05">
EDIT2: add txp: in front of the plugin name ;-)
Last edited by Bloke (2008-11-14 17:04:45)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#140 2008-11-14 14:59:31
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Hoi Bloke,
It’s correct that i want to check the value of the month variable in the url.
One question : Can i nest it ?
Roelof
Offline
#141 2008-11-14 15:04:16
Re: smd_if: Generic multiple if condition tests
roelof wrote:
Can i nest it ?
You can’t nest smd_if calls under TXP 4.0.6, no. The same as all other tags. That’s partly the reason I added the in operator (see Edit in above post), so you could check multiple values without nesting. Under 4.0.7 the nesting restriction is lifted.
Last edited by Bloke (2008-11-14 15:04:36)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#142 2008-11-14 15:49:32
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
oke,
It’s a pity but i can live with it.
Thank you for the help en tips.
Roelof
Offline
#143 2008-11-14 16:51:04
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Hoi Bloke,
I have a problem.
I use this in my page template :
<txp:if_section name=”,default”>
<txp:if_category name=“zwangerschap,jaar1,jaar2,jaar3,jaar4”>
<smd_if field=“urlvar:month” operator=“in” value=“2005-04”>
<txp:article limit=“1” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
</smd_if>
<smd_if field=“urlvar:month” operator=“in” value=“2005-02, “2005-03”>
<txp:article limit=“5” form=“dagboek” sort=“Posted asc” />
</smd_if>
<txp:else />
<txp:article_custom section=“voorpagina” form=“default” />
</txp:if_category>
</txp:if_section>
But if i look in the tag trace the plugin isn’t doing one thing.
I have enabled it in the plugin sections.
Do you have any idea why nothing happens with the plugin.
Roelof
Offline
#144 2008-11-14 17:02:59
Re: smd_if: Generic multiple if condition tests
roelof wrote:
Do you have any idea why nothing happens with the plugin.
You need to add txp: in front of the smd_if plugin name ;-)
Sorry, I didn’t spot that when I copy n pasted your example, I’ve gone back and fixed the code in my post.
Last edited by Bloke (2008-11-14 17:05:50)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#145 2008-11-14 17:36:42
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
oke,
Still one problem.
I changed everything to :
bc.<txp:if_section name=”,default”>
<txp:if_category name=“zwangerschap,jaar1,jaar2,jaar3,jaar4”>
<txp:smd_if field=“urlvar:month” operator=“in” value=“2005-04”>
<txp:article limit=“1” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” />
</txp:smd_if>
<txp:smd_if field=“urlvar:month” operator=“in” value=“2005-02, “2005-03”>
<txp:article limit=“5” form=“dagboek” sort=“Posted asc” />
</txpsmd_if>
<txp:else />
<txp:article_custom section=“voorpagina” form=“default” />
</txp:if_category>
</txp:if_section>
But now i get this messages :
<txp:smd_if field="urlvar:month" operator="in" value="2005-02, "2005-03">
<txp:article limit="5" form="dagboek" sort="Posted asc" /> -> Textpattern Notice: niet bestaand tagattribuut: limit on line 653
textpattern/lib/txplib_misc.php:653 trigger_error()
textpattern/lib/txplib_misc.php(574) : eval()'d code:14 lAtts()
textpattern/publish.php:970 smd_if()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2718 parse()
textpattern/publish.php:970 if_category()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2777 parse()
<txp:smd_if field="urlvar:month" operator="in" value="2005-02, "2005-03">
<txp:article limit="5" form="dagboek" sort="Posted asc" /> -> Textpattern Notice: niet bestaand tagattribuut: form on line 653
textpattern/lib/txplib_misc.php:653 trigger_error()
textpattern/lib/txplib_misc.php(574) : eval()'d code:14 lAtts()
textpattern/publish.php:970 smd_if()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2718 parse()
textpattern/publish.php:970 if_category()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2777 parse()
<txp:smd_if field="urlvar:month" operator="in" value="2005-02, "2005-03">
<txp:article limit="5" form="dagboek" sort="Posted asc" /> -> Textpattern Notice: niet bestaand tagattribuut: sort on line 653
textpattern/lib/txplib_misc.php:653 trigger_error()
textpattern/lib/txplib_misc.php(574) : eval()'d code:14 lAtts()
textpattern/publish.php:970 smd_if()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2718 parse()
textpattern/publish.php:970 if_category()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2777 parse()
<txp:else/> -> Textpattern Warning: on line 983
textpattern/publish.php:983 trigger_error()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2718 parse()
textpattern/publish.php:970 if_category()
processTags()
textpattern/publish.php:929 preg_replace_callback()
textpattern/publish/taghandlers.php:2777 parse()
textpattern/publish.php:970 if_section()
processTags()
-> Textpattern Notice: De modelpagina default heeft nog geen txp:article tag on line 474
textpattern/publish.php:474 trigger_error()
index.php:40 textpattern()
regards,
Roelof
Last edited by roelof (2008-11-14 17:37:33)
Offline
#146 2008-11-14 17:57:38
Re: smd_if: Generic multiple if condition tests
Not sure if this is related to your problem, but there is a
</txpsmd_if> (the : is missing)
in your code
Offline
#147 2008-11-14 19:45:34
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
Thank you,
You can see it works (http://test2.tamarawobben.nl
Roelof
Offline
#148 2008-11-15 13:53:58
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
i have another problem.
I have this url :
http://test2.tamarawobben.nl/?c=zwangerschap&month=2005-04
the next pages have this url :
http://test2.tamarawobben.nl/?pg=2&s=default&c=zwangerschap&month=2005-04
Now i thought that i can use this to determine how many articles must be on the first page.
<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“in,isempty” value=“2005-04”, >
<txp:article limit=“1” form=“dagboek” sort=“Posted asc” />
<txp:ob1_pagination outputlastfirst =“0” outputnextprevious=“0” liselected=“here”
/>
</txp:smd_if>
But it doesn’t work.
Can you tell me why ?
Roelof
Offline
#149 2008-11-15 14:38:40
Re: smd_if: Generic multiple if condition tests
roelof wrote:
<txp:smd_if field=“urlvar:month, urlvar:pg” operator=“in,isempty” value=“2005-04”, >
Assuming the extra comma and space at the end of the tag isn’t making it break…
That statement says:
IF the ?month variable is 2005-04 AND the ?pg variable is defined but has no value (i.e. http://some/url?pg=) THEN show the article and ob1_pagination. Otherwise, don’t show anything.
Is that what you want to achieve?
I don’t know if you can ‘determine’ how many articles to put on the front page, since TXP determines that for you based on how many articles (in total) are in the category and the value to which you set the limit attribute.
Last edited by Bloke (2008-11-15 14:39:11)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#150 2008-11-15 15:18:27
- roelof
- Member
- Registered: 2005-03-27
- Posts: 647
Re: smd_if: Generic multiple if condition tests
what i want to achieve is :
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.
I want to detirme if i have this url (http://test2.tamarawobben.nl/?c=zwangerschap&month=2005-04) or this one : http://test2.tamarawobben.nl/?pg=2&s=default&c=zwangerschap&month=2005-04.
One have a pg variable the other don’t have this.
Roelof
Offline