Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#136 2017-12-13 14:29:21
Re: smd_macro: Create custom virtual Txp tags that do stuff
jakob wrote #308296:
I get a
syntax error, unexpected 's' (T_STRING)on that page.The unregistered tag probably just means this is missing from the beginning of the “Begin public code” part of the smd_if plugin:
if (class_exists('\Textpattern\Tag\Registry')) {....Aside from the error, do you still get the correct output?
Even with ‘registering the tag’, the whole page chokes although nothing else is revealed when setting the site on debug mode. I have some more info on ps2 above.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#137 2017-12-13 14:38:55
Re: smd_macro: Create custom virtual Txp tags that do stuff
I added a note too about ps2. Was just wondering whether smd_if is trying to process some special characters or words in the field attribute (i.e. the caption text) – like ON or &, or ; or , – and that that might be triggering the problem.
TXP Builders – finely-crafted code, design and txp
Offline
#138 2017-12-13 15:33:18
Re: smd_macro: Create custom virtual Txp tags that do stuff
Weird, but testing a caption like that as a field is prone to breakage since it doesn’t escape the field name. You might have more luck with:
<txp:smd_if field="SMD_NONE" operator="eq" value="{caption}">
Or try escaping the content with :ESC or :ESCALL:
<txp:smd_if field="{caption}:ESCALL" operator="eq" value="SMD_NONE">
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
#139 2017-12-14 04:53:04
Re: smd_macro: Create custom virtual Txp tags that do stuff
I think I got it. I had No Land's Man in a caption. The apostrophe was chocking the page even with :ESC or :ESCALL. I changed it to No Land’s Man and all seems to be working fine.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#140 2018-02-28 14:04:27
Re: smd_macro: Create custom virtual Txp tags that do stuff
I have my first macro, a popular one, I’m guessing. But the caption is not outputting. Instead I’m just getting “SMD_NONE”. Following is the macro.
Attributes table.
| Name | Default | Replacement name |
|---|---|---|
| id | img_id | |
| caption | SMD_NONE | caption |
| class | SMD_NONE | class_value |
Macro markup:
<figure<txp:smd_if field="{class}" operator="eq" value="SMD_NONE"><txp:else /> class="{class_value}"</txp:smd_if>>
<txp:image id="{img_id}" />
<txp:smd_if field="{caption}" operator="eq" value="SMD_NONE">
<figcaption><txp:image_info id="{img_id}" type="caption" /></figcaption>
<txp:else />
<txp:smd_if field="NULL" operator="eq" value="{caption}">
<txp:else />
<figcaption>{caption}</figcaption>
</txp:smd_if>
</txp:smd_if>
</figure>
It outputs the image fine, uses the class as desired, but the caption is not the one in the caption field, which reads, “An example of endnotes and back-links employed in Wikipedia.”.
I must be overlooking a typo or something?
Update: Code above is now correct and working. (Thanks, Bloke.) Use it safely and well!
Last edited by Destry (2018-02-28 14:16:33)
Offline
#141 2018-02-28 14:06:36
Re: smd_macro: Create custom virtual Txp tags that do stuff
Destry wrote #309526:
I must be overlooking a typo or something?
<txp:smd_if field="{caption}" operator="eq" value="SMD_NONE">
With the curly braces?
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
#142 2018-02-28 14:13:58
Re: smd_macro: Create custom virtual Txp tags that do stuff
:) Merci !
Offline
#143 2018-06-03 09:50:13
Re: smd_macro: Create custom virtual Txp tags that do stuff
I am trying to create an eu compliant way of loading our videos from vimeo. I thought that the easiest way would be to create a macro but it does not work. This is what I have in the definition field.
<txp:oui_cookie name="accept_vimeo_cookies" values="yes" />
<txp:oui_if_cookie name="accept_vimeo_cookies">
<div class="embed-container" id="vimeo2">
<txp:linklist category="{cat}" limit="100" sort="id asc" form="" wraptag="div" class="slider">
<div class="slide">
<iframe src="https://player.vimeo.com/video/<txp:link_description escape="" />?title=0&byline=0&portrait=0" allowfullscreen></iframe>
</div>
</txp:linklist>
</div>
<txp:else />
<div id="vimeoeucookies" class="noprint">
<p class="centre">These videos, presenting {presenting} are hosted by Vimeo on
<txp:linklist category="{cat}" limit="100" sort="id asc" form="" wraptag="" break=", ">
<a rel="external" href="https://vimeo.com/<txp:link_description escape="" />">vimeo.com/<txp:link_description escape="" /></a>
</txp:linklist>.
</div>
</txp:oui_if_cookie>
The above only returns
These videos, presenting talks by are hosted by Vimeo on .
Indicating that the {presenting} attribute is working but the linklist is not parsed.
The macro I use is <txp:euvids cat="link_category_name" presenting="something here" />.
and here is the screeshot

Any help or advice would be greatly appreciated
Edit: SOLVED
Last edited by colak (2018-06-03 15:07:40)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#144 2018-06-04 11:42:56
Re: smd_macro: Create custom virtual Txp tags that do stuff
FYI, I think anything you could have done with smd_macro can now be done natively with tags.
Others will know better than I about limits, if any.
But if first para above is true, then the prudent way forward is to build native shortcodes instead of using the plugin, as the plugin may become obsolete.
Offline
#145 2018-06-04 13:08:56
Re: smd_macro: Create custom virtual Txp tags that do stuff
Yes, if you’re using 4.7.0 and can use a native shortcode, now would be a good time to migrate it. You can do everything in a shortcode you can do in a smd_macro. I will probably deprecate this plugin at some point.
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
#146 2018-06-04 14:44:43
Re: smd_macro: Create custom virtual Txp tags that do stuff
Bloke & Destry wrote
use native shortcode
Hmmm. I see the examples are making heavy use of the yield tag. Although I read many explanations about it in this forum, i did not really understand it yet. I will experiment though as I always prefer using native tags.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#147 2018-06-05 16:53:35
Re: smd_macro: Create custom virtual Txp tags that do stuff
Just thought I’ll stop in to say that I have replaced all the smd_macros with native shortcode and it works wonderfully!!! It took less than half a day to write the shortcodes and search and replace all instances I had in the articles. This feature is an amazing leap forward for txp which deserved a jump to version 5.0!!! Way to go guys!!!!
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#148 2018-06-05 22:56:12
Re: smd_macro: Create custom virtual Txp tags that do stuff
Yes, native shortcode is amazingly magic. Once you ”get” <txp:yield / the sky is the limit.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg
Offline
#149 2018-06-06 08:39:47
Re: smd_macro: Create custom virtual Txp tags that do stuff
colak wrote #312354:
This feature is an amazing leap forward for txp
Another satisfied customer :) I love it too.
Thank Oleg, it was his idea. And Jukka for making rah_beacon in the first place, on which this feature is based.
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
#150 2018-06-06 09:01:00
Offline