2010-09-29 01:37:29

maniqui
Moderator
omega
Real name: Julián
From: Buenos Aires, Argentina
Known languages: es,en

Re: smd_if: Generic multiple if condition tests

saccade, you are welcome.
BTW, you could have used txp:if_article_section, couldn’t you?


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

 

2010-09-29 01:57:13

saccade
Plugin Author
lambda
Real name: Michael Schlierbach
From: Raubling, Germany
Known languages: de, en

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

 

2011-02-24 11:30:53

husainhk
Member
zêta
Real name: Husain
From: Dubai, UAE
Website

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

 

2011-02-24 12:27:40

merz1
Member
pi
Real name: Markus Merz
From: Hamburg
Known languages: German, English
Website

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:

  1. Nine articles
  2. No custom field
  3. 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

 

2011-02-24 13:30:48

alanfluff
Member
êta
Real name: Alan
From: Ottawa, Canada
Known languages: English
Website

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

 

2011-02-28 02:16:00

mericson
Member
zêta
Real name: Mark
Website

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

 

2011-02-28 09:12:16

Bloke
Developer
omega
Real name: Stef Dawson
From: Leeds, UK
Known languages: Engl(ish)
Website

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.

Txp Builders – finely-crafted code, design and Txp

Offline

 

2011-02-28 14:13:17

alanfluff
Member
êta
Real name: Alan
From: Ottawa, Canada
Known languages: English
Website

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

 

2011-02-28 22:30:24

Bloke
Developer
omega
Real name: Stef Dawson
From: Leeds, UK
Known languages: Engl(ish)
Website

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.

Txp Builders – finely-crafted code, design and Txp

Offline

 

2011-02-28 23:52:08

alanfluff
Member
êta
Real name: Alan
From: Ottawa, Canada
Known languages: English
Website

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

 

Powered by FluxBB