Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#397 2012-12-12 21:10:52

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: smd_if: Generic multiple if condition tests

uli dijo:

Without plugin?
status 5 is sticky, right? (No further proofreading done.)

Yes, I use an sticky article just to describe different categories. About your code, it works! but I’ve modified it as follows:

<txp:variable name="checkcheck"><txp:article_custom form="body" limit="1" section='<txp:section />' sort="Posted asc" status="sticky" category='<txp:category title="0" />' /></txp:variable>
<txp:if_variable name="checkcheck" value="">
<p>NO THERE CONTENT IN BODY ARTICLE</p>
<txp:else/>
<txp:variable name="checkcheck" />
</txp:if_variable>

I thought I couldn’t store big chains text in a TXP variable :P
Many thanks

Offline

#398 2012-12-12 21:19:12

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,303

Re: smd_if: Generic multiple if condition tests

gfdesign wrote:

but I’ve modified it as follows:

Ah, the slash in the closing variable tag. Glad it didn’t make you stumble. Will correct that above.

I thought I couldn’t store big chains text in a TXP variable :P

Me neither, but I learnt it even spares one query.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#399 2012-12-12 21:20:10

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: smd_if: Generic multiple if condition tests

GugUser dijo:

Or:
bq. <txp:if_custom_field name=“body”> something
<txp:else /> other thing
</txp:if_custom_field> 

In this case, I’m not using custom_field
I wondered with body or excerpt texts of an article.
Regards

Last edited by gfdesign (2012-12-12 21:24:39)

Offline

#400 2012-12-12 23:33:11

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: smd_if: Generic multiple if condition tests

The example checks the body field.

Offline

#401 2012-12-13 15:56:45

merz1
Member
From: Hamburg
Registered: 2006-05-04
Posts: 994
Website

Re: smd_if: Generic multiple if condition tests

Documentation needs enhancement(s) regarding TXP core fields which can be checked via if_custom_field name="list of TXP core fields".

www.textpattern.net/wiki/index.php?title=if_custom_field


Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML

Offline

#402 2012-12-21 16:29:19

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Re: smd_if: Generic multiple if condition tests

Can I check for article status?

Offline

#403 2012-12-21 16:35:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,243
Website GitHub

Re: smd_if: Generic multiple if condition tests

wornout wrote:

Can I check for article status?

As in Live, Sticky, etc? Or as in HTTP status (200, 403, 404, …)?


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

#404 2012-12-21 16:37:26

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Re: smd_if: Generic multiple if condition tests

As in live, sticky….

Offline

#405 2012-12-21 16:42:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,243
Website GitHub

Re: smd_if: Generic multiple if condition tests

wornout wrote:

As in live, sticky….

Yes, for example:

<txp:smd_if field="article:status" operator="in" value="4/5">
  LIVE OR STICKY
<txp:else />
  HIDDEN, PENDING OR DRAFT
</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

Offline

#406 2013-01-16 17:28:59

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Re: smd_if: Generic multiple if condition tests

How can I check the current section?

<txp:smd_if field="s" value="usate,nuove" operator="or">

This work only for the first value…

Last edited by wornout (2013-01-16 17:29:40)

Offline

#407 2013-01-16 17:56:51

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,243
Website GitHub

Re: smd_if: Generic multiple if condition tests

wornout

Try logic="or" instead.


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

#408 2013-01-21 04:17:00

gfdesign
Member
From: Argentina
Registered: 2009-04-20
Posts: 401

Re: smd_if: Generic multiple if condition tests

Sorry, likely I’m asking for something dumb but I can’t realize how to use this plugin for testing if body or excert fields are empty.
I’m using next codes:

<txp:smd_if field="body" operator="eg" value="">
<p>empty body</p>
<txp:else /> 
<div class="body">
<txp:article_custom form="body" pgonly="0" limit="1" sort="Posted asc" status="5" />
</div><!-- fin "body" -->
</txp:smd_if>

or

<txp:smd_if field="excerpt" operator="isempty" >
<p>empty excerpt</p>
<txp:else /> 
<div class="excerpt">
<txp:article_custom form="excerpt" pgonly="0" limit="1" sort="Posted asc" status="5" />
</div><!-- fin "excerpt" -->
</txp:smd_if>

However I don’t achieve they work. Would someone give a hand?
Many thanks and my appologies for my ignorance
Regards

Offline

Board footer

Powered by FluxBB