Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#133 2017-11-13 16:09:32
Re: smd_macro: Create custom virtual Txp tags that do stuff
Thanks so much jp… I was so blind to it… It’s now working as intended
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#134 2017-12-13 13:45:30
Re: smd_macro: Create custom virtual Txp tags that do stuff
Well… a month later and there is something wrong which breaks the page:)
Here is a screenshot of the macro:
Here is the code:
<figure itemscope itemtype="http://schema.org/ImageObject" class="{class}">
<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>
and here is the front end error on this page.:
Tag error: <txp:smd_if field="ONR Nicosia Wall 1" operator="eq" value="SMD_NONE"> -> Textpattern Notice: unregistered_tag while parsing form None on page artworks
ps. This is the code used in the page: <txp:figure id="104" class="grid_6 clearleft" caption="ONR Nicosia Wall 1" />
ps2. I am testing the page which has about 35 figures.
After deleting all except the first one (code above), all is working and also works when including the 2nd one. When I add the 3rd, <txp:figure id="126" class="grid_6" caption="Moved Wall by Adriana Frias Gonçalves, Ana Sofia Sousa Soares, Ana Filipa Santos Pimenta, and Nico Carpentier" />
, the page breaks… Does anyone have any idea?
Last edited by colak (2017-12-13 14:19:41)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#135 2017-12-13 14:23:24
Re: smd_macro: Create custom virtual Txp tags that do stuff
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')) {
Txp::get('\Textpattern\Tag\Registry')
->register('smd_if')
;
}
Aside from the error, do you still get the correct output?
EDIT: What happens if you just specify caption="Nicosia Wall 1"
and leave out the ONR? I wonder if it’s processing “ON” somehow. Try also ç instead of the entity with & and ; in it.
TXP Builders – finely-crafted code, design and txp
Offline
#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.
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.
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