Textpattern CMS support forum

You are not logged in. Register | Login | Help

#41 2008-01-16 18:19:23

draganbabic
Member
From: Novi Sad, Serbia
Registered: 2006-09-27
Posts: 115
Website

Re: smd_if: Generic multiple if condition tests

Ignore my desperate cry for help. :)

The problem was within <txp:smd_if field=“projecten_item_1” operator=“contains” value=”.swf”>

Offline

#42 2008-01-16 21:10:56

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,622
Website

Re: smd_if: Generic multiple if condition tests

Well spotted! Glad it works now; I scratched my head for a bit and wondered if the plugin was broken… phew!


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

#43 2008-01-17 19:21:38

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: smd_if: Generic multiple if condition tests

Hi Stef, just wanted to say a huge thank you for this amazing plugin – it adds a whole new dimension to what can be done with TxP.

Last edited by lee (2008-01-17 19:22:01)

Offline

#44 2008-02-20 15:40:46

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: smd_if: Generic multiple if condition tests

Ok I got a little problem:

I’m trying to build a custom archive. So far, what I’ve achieved, is url’s looking like this: http://www.madebyelephant.com/blog/?archive=2008-02

Now, how can I check if the ?archive= part is in the url? <txp:smd_if field="urlvar:archive"> made my template go bonkers…

EDIT

Ok I read through this thread, and changed my code to the following:

<txp:smd_if field="urlvar:archive" operator="defined" value=",">
	<p>Success!</p>
<txp:else />
	[Display the default]
</txp:smd_if>

The problem is it gives me a blank page…

EDIT 2

I am a complete moron. Forgot a <txp:else /> somewhere else on the page…

Move on please :-)

Last edited by maxvoltar (2008-02-20 16:14:13)


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#45 2008-02-20 20:55:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,622
Website

Re: smd_if: Generic multiple if condition tests

maxvoltar wrote:

Hi, sorry I didn’t get to this earlier. Sounds like you got it sorted without me, though :-)

changed my code to the following: <txp:smd_if field=“urlvar:archive” operator=“defined” value=”,”> …

fwiw, in the latest version you shouldn’t need the value attribute in this situation as the plugin’s defaults are a bit more sensible based on the operators you give it. Since defined doesn’t require a value and it’s the only operator in your test, you can safely omit the value.

Last edited by Bloke (2008-02-20 20:57:03)


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

#46 2008-02-20 21:55:29

maxvoltar
Member
From: Machelen, Belgium
Registered: 2007-08-16
Posts: 76
Website

Re: smd_if: Generic multiple if condition tests

@Bloke: I wrote an article about your plugin (and, how you can use it to create your own archives): http://www.madebyelephant.com/blog/creating-archives-in-textpattern

Last edited by maxvoltar (2008-02-20 21:55:45)


Textpattern projects: Maxvoltar, Made by Elephant, Twunch

Offline

#47 2008-02-20 21:58:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,622
Website

Re: smd_if: Generic multiple if condition tests

Nice one, thanks for sharing the tip :-)


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

#48 2008-02-21 23:30:33

photonomad
Member
Registered: 2005-09-10
Posts: 287
Website

Re: smd_if: Generic multiple if condition tests

This is a wonderful plugin!

One question: I am using one of my custom fields for a URL and if the custom field does not contain/begin with “http://” , then I do not want smd_if to output that field. I can’t find an operator that tests for either “does not contain” or “does not begin with”

I would use isempty or undefined, but the person who will be using the site is not super web-savvy and there is a possibility she will enter a URL without the requisite “http://”

Is there a way to do this with the existing plugin or would this have to be added to the functionality of the plugin?

Thanks!

Offline

#49 2008-02-21 23:50:22

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,622
Website

Re: smd_if: Generic multiple if condition tests

photonomad wrote:

if the custom field does not contain/begin with “http://” , then I do not want smd_if to output that field.

Unless I’ve totally misunderstood what you’re trying to do, can you swap the logic round so that it becomes: if the custom field does contain/begin with “http://” then you do want to output the field?

Or can you make use of <txp:else /> to test for the positive case and put your code in the else branch to “negate” the logic? i.e.

<txp:smd_if field="custom1" operator="begins" value="http://">
// output the field
<txp:else />
// don't output the field
</txp:smd_if>

(in fact the else might not even be necessary if you don’t want to take any action if the field is empty)

If I’ve got the wrong end of the stick, hammer the message home in another post and I might get it :-)


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

#50 2008-02-26 17:17:20

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: smd_if: Generic multiple if condition tests

Hello

Sorry to be a numpty, but I can’t get this plugin to do what I hoped. I suspect the problem is with my implementation rather than the plugin.

On my homepage I have a simple list of permalinks to articles pulled from across the site. I’m trying to test for the parent category of each article’s category1 value and append some text to the link where appropriate.

The relevant bit of the category structure is
  • TRAVEL
    • Croatia (0)
    • France (0)
    • Greece (0)
    • etc

The site admin can add new countries as subcategories as they arise, so I can’t hard-code a test for the actual value of category1 (the parent TRAVEL category is just a guide to keep the category menu tidy – it won’t ever be assigned itself).

This is what I have in my article form…

<txp:smd_if field="parent" operator="begins" value="TRAVEL"> (Travel review)</txp:smd_if>

Is the problem that this isn’t being used in a category page? I spose I’m actually trying to test for the article_category rather than the global one. Hope that makes sense.

many thanks
Stu

Offline

Board footer

Powered by FluxBB