Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#466 2018-08-27 03:29:11

lazlo
Member
Registered: 2004-02-24
Posts: 110

Re: smd_if: Generic multiple if condition tests

Hey Stef

Not sure if this affects anyone else but I upgraded a 4.5.7 site to smd_if 1.00 it didn’t work for me, I had to downgrade to 0.92. I didn’t see a version listing on the front page of plugin support or your page.

- L

Last edited by lazlo (2018-08-27 07:40:12)

Offline

#467 2018-10-27 16:56:16

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_if: Generic multiple if condition tests

Wondering if this is possible, or if there’s another way to get to it…

I have a partial of snake teeth that checks if there’s an article image or not and does its slither dance either way. The image is used as a hero and marked up as a figure so I can make use of the caption.

<txp:if_article_image>
      <hr>
      <p class="excerpt"><txp:excerpt escape="trim, tidy" /></p>
      <figure class="hero">
         <txp:article_image height="0" width="0" />
         <figcaption>
              <txp:image_info id='<txp:custom_field name="article_image" />' type="caption" escape="tidy,textile" />
          </figcaption>
      </figure>
    <txp:else />
      <hr class="startrule">
      <p class="excerpt"><txp:excerpt escape="trim, tidy" /></p>
      <hr class="endrule">
</txp:if_article_image>

Now, of course, I’ve run into a possible situation where I might not want every hero to have a caption. I can not add a caption in the field, but the figcaption pair still outputs. I couldn’t think how to get around this with core tags, so I thought maybe smd_if would be the ticket, but the docs are a tad obtuse for this peckerwood.

First I tried and hoped the new not functionality would work:

<txp:smd_if field="caption" not value="NULL">
     <figcaption>
         <txp:image_info id='<txp:custom_field name="article_image" />' type="caption" escape="tidy,textile" />
     </figcaption>
</txp:smd_if>

No dice.

Then I tried what I though was a shoe-in (note the else tag):

<txp:smd_if field="caption" value="NULL"><txp:else />
     <figcaption>
         <txp:image_info id='<txp:custom_field name="article_image" />' type="caption" escape="tidy,textile" />
     </figcaption>
</txp:smd_if>

Still nothing. An empty <figcaption></figcaption> still outputs.

Am I using the ‘NULL’ correctly?

Harlp?

Offline

#468 2018-10-27 17:11:32

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,200
Website GitHub

Re: smd_if: Generic multiple if condition tests

How about not using smd_if (sorry Stef) and using either the attribute wraptag="figcaption":

<txp:image_info id='<txp:custom_field name="article_image" />'
                type="caption" escape="tidy,textile"
                wraptag="figcaption" />

(you can write that all in one line) or if that doesn’t work as desired, using txp:evaluate to only output the code block when the tag returns a value:

<txp:evaluate test="image_info">
    <figcaption>
        <txp:image_info id='<txp:custom_field name="article_image" />' type="caption" escape="tidy,textile" />
    </figcaption>
</txp:evaluate>

TXP Builders – finely-crafted code, design and txp

Offline

#469 2018-10-27 17:15:27

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,384
Website GitHub Mastodon Twitter

Re: smd_if: Generic multiple if condition tests

Hi Destry,
Just to let you know that you can also do what you are trying to achieve without a plugin.

<txp:variable name="capt" value='<txp:images id='<txp:custom_field name="article_image" />' /></txp:images>' />
<txp:if_variable name="capt" value="">
<txp:else />
<figcaption>
<txp:image_info id='<txp:custom_field name="article_image" />' type="caption" escape="tidy,textile" />
</figcaption>
</txp:if_variable>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#470 2018-10-27 17:56:11

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,912
Website

Re: smd_if: Generic multiple if condition tests

As usual, there are multiple roads to the doghouse.

I really need to learn those variable and evaluate tags better. I think I’ll go with the evaluate trick this time around.

Thank you.

Offline

#471 2020-01-12 10:18:26

Sunfoot
Member
From: Felanitx
Registered: 2009-02-07
Posts: 16
Website

Re: smd_if: Generic multiple if condition tests

Hello

Does this plugin work on Textpattern 4.8 Beta?

Admin-side theme: hive 4.8.0-beta
Active plugins:
smd_if-1.0.0

I get the warning message that it is not registered.
No idea what is wrong.
My php version is 7.2.10

Felix

Offline

#472 2020-01-12 10:27:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,451
Website GitHub

Re: smd_if: Generic multiple if condition tests

Huh. Swear I registered this plugin’s tags. I’ll get it done today and release it, sorry.


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

#473 2020-01-12 10:38:21

Sunfoot
Member
From: Felanitx
Registered: 2009-02-07
Posts: 16
Website

Re: smd_if: Generic multiple if condition tests

Bloke wrote #321047:

Huh. Swear I registered this plugin’s tags. I’ll get it done today and release it, sorry.

I love you!

Felix

Offline

#474 2020-01-12 23:56:01

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,451
Website GitHub

Re: smd_if: Generic multiple if condition tests

There you go. Try smd_if v1.0.0 which has the tag registered and a few other minor fixes.


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

#475 2025-12-17 10:56:31

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: smd_if: Generic multiple if condition tests

Hi Stef

When on testing mode i got those errors:
Erreur de balise : <txp:smd_if field=“postvar:ccom” operator=“undefined”> <p>Coucou</p> </txp:smd_if> -> Warning: Undefined array key “ccom” lors du traitement du module “Aucun” dans le gabarit “livre”

I use pluggin version 1.0 and txp 4.8.8 and php 8.0,
When switching to php 7.4 those errors disapear.

Thanks.

Offline

#476 2025-12-17 10:58:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,451
Website GitHub

Re: smd_if: Generic multiple if condition tests

Thanks for the report. Are you able to please add this is an Issue on the repo so I don’t lose track?


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

#477 2025-12-17 13:17:39

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: smd_if: Generic multiple if condition tests

The issue added.

Thanks stef.

Offline

Board footer

Powered by FluxBB