Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#361 2010-09-29 01:37:29
Re: smd_if: Generic multiple if condition tests
saccade, you are welcome.
BTW, you could have used txp:if_article_section, couldn’t you?
Offline
#362 2010-09-29 01:57:13
- saccade
- Plugin Author
- From: Neubeuern, Germany
- Registered: 2004-11-05
- Posts: 521
Re: smd_if: Generic multiple if condition tests
Maniqui: Blame me – I could, of course. Why on earth didn’t I think about that? (Surely because I had some more difficult things in mind I wanted to do with smd_if.)
But of course
<txp:if_article_section name='<txp:sac_special_groups_privs />' > ... <txp:else /> ... </txp:if_article_section>
should do as well. I even had planned my special_groups_privs-code to get a comma-separated list needed for such a thing.
Thank you for pointing into that direction! :)
Offline
#363 2011-02-24 11:30:53
Re: smd_if: Generic multiple if condition tests
Am facing a really weird situation while displaying articles on the default page that have custom fields. When using the code below, I see nothing and surprisingly if I change the limit to 999, that articles show. I tried this with the if_custom_field tag as well, and it’s the same, so not sure what could be going wrong…
on default page:
<ul>
<txp:article_custom section="my-section" limit="9" form="some-form" sort="rand()" />
</ul>
in some-form:
<txp:smd_if field="my_custom_field_name" operator="eq" value="yes">
<li><a href="<txp:permlink />">Some link in here</a></li>
</txp:smd_if>
Appreciate any help!
Offline
#364 2011-02-24 12:27:40
Re: smd_if: Generic multiple if condition tests
Husain it would be helpful to know if the limit="9"
output has articles with value="yes"
.
Logic:
- Nine articles
- No custom field
- No output
Edit: Please check Display 5 most recent articles with same custom field value
Edit2: From article_custom doc (see example 4)
customfieldname=“value”
- Restrict to articles with specified value for specified custom field name. Replace “customfieldname” with the name of the custom field.
- Default: unset.
Edit3: Code
<txp:article_custom section="my-section"
my_custom_field_name="yes"
limit="9"
sort="rand()"
wraptag="ul"
break="li">
<a href="<txp:permlink />">Some link in here</a>
</txp:article_custom>
PS: Through this TXP core tag solution the problem becomes off topic as no txp:smd_if
is needed anymore :)
Last edited by merz1 (2011-02-24 12:44:32)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#365 2011-02-24 13:30:48
Re: smd_if: Generic multiple if condition tests
husainhk
merzi has answered this much better than I could have, but I would guess in simple terms the reason this has happened is:
the line
<txp:article_custom section="my-section" limit="9" form="some-form" sort="rand()" />
is telling TXP to go look at the first 9 articles. The form you use looks through 9 articles and any it find with your custom field set the way you want, it returns. After the 9, it returns. So, if the articles you are looking for are not in the first 9, you won’t see any.
I’ve had this too.
What I do is set the limit to 999 and then in the subsequent form, I limit the return to 9. I think I do that limit by doing a second article_custom, but I’m not certain and not able to check right now.
Hope that helps explain at least. Good luck! Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#366 2011-02-28 02:16:00
Re: smd_if: Generic multiple if condition tests
I tried searching, but couldn’t find an answer… can someone provide a example of how I would use smd_if to test for localhost (or maybe specific domain)? I see I could use aam_if_host, but it would be nice if I didn’t have to install another plugin
Offline
#367 2011-02-28 09:12:16
Re: smd_if: Generic multiple if condition tests
mericson wrote:
how I would use smd_if to test for localhost (or maybe specific domain)?
Try something like this (untested) :
<txp:smd_if field="svrvar:SERVER_NAME" operator="in"
value="localhost/somedomain.com/otherdomain.com">
<p>Yep, it's one of the domains in the list</p>
<txp:else />
<p>Nope, not one of the domains</p>
</txp:smd_if>
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
Online
#368 2011-02-28 14:13:17
Re: smd_if: Generic multiple if condition tests
Hey Stef,
Does this mean a holy grail of settings-ness I would love to have could be constructed (I assume not but had to ask)
File: /textpattern/config.php
<txp:smd_if this_is_my_dev_domain>
<my dev/local settings />
<txp:else />
<my live/web settings />
</txp:smd_if>
?
Thanks for any comment :) Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#369 2011-02-28 22:30:24
Re: smd_if: Generic multiple if condition tests
alanfluff wrote:
Does this mean a holy grail of settings-ness I would love to have could be constructed
Nice thought, but sadly not. In config.php
you can’t run plugins (they’re not loaded at the point it’s read) so you’d still have to do this kind of thing by hand. And even if you could, using smd_if is probably like beating a thumb tack into the wall with a snowboard!
Last edited by Bloke (2011-02-28 22:32:28)
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
Online
#370 2011-02-28 23:52:08
Re: smd_if: Generic multiple if condition tests
Thanks Stef, guessed I was likely to be unlucky there. Cheers, -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#371 2011-03-07 06:46:52
Re: smd_if: Generic multiple if condition tests
Yes, that appears to work! And, you taught a man to fish. I realized for my specific ‘localhosting’ need, the server IP address is probably easier, so changing your example to:
<txp:smd_if field="svrvar:SERVER_ADDR" operator="eq" value="127.0.0.1">
<p>Yes, it is localhost</p>
<txp:else />
<p>Nope, not localhost</p>
</txp:smd_if>
Thanks!
Offline
#372 2011-03-23 17:13:20
Re: smd_if: Generic multiple if condition tests
Howdy!
Quick report. This works fine for me:
<txp:smd_if field="txpvar:parent_topic" operator="in" value="x/y/z">
But if I set the list delimiter to a comma by declaring list_delim=","
and use a comma to separate the values, it doesn’t work any more.
For now, I don’t absolutely need the commas, so I’m keeping the default, I just though comma-separated values would be more consistent with the way the rest of Textpattern works.
Offline