Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Short-tags and shortcodes
Haven’t see many people talking about this new feature yet, though granted there’s a lot of new to absorb lately. Hope I’m not stepping on toes by saying anything, but I did a little docs editing the last couple of days and…
- The extra eyes on changes would be nice in case it’s flat wrong (advancing the copy of others before me) or undecipherable.
- You might want to know about this cool new feature.
I’ll let the docs do the talking:
- Core short-tags
- Custom short-tags and shortcodes (Basically, we now have core functionality in 4.7.0 that makes plugins like smd_macro and rah_beacon somewhat obsolete. )
- Shortcode examples
And I just contributed my own example, Aside-quotes shortcode. It seems to be working good, just as it was as a macro. I’ve got smd_macro removed now and all is well.
If you come up with your own shortcode solutions to things, do share them.
Tag powa!
Btw, if you do find problems with those pages, please start an issue as the links at bottoms of pages request.
Offline
Re: Short-tags and shortcodes
Excellent!
The only thing I noticed off hand was:
- On custom short tags you have a stray
`
in the final code example. - On the other pages you have a few attributes with textilised quotes rather than straight quotes.
Looking at your/the shortcode examples made me wonder whether we could make txp:yield
a little more flexible…
TXP Builders – finely-crafted code, design and txp
Offline
Re: Short-tags and shortcodes
I added a new section (the last one) to the “aside-quotes shortcode” doc, showing what the shortcode would be like with short-tags used. There is not a big difference in this case, a savings of 10 characters.
But it got me wondering, is the short-tags preference for core short-tags only, or for both core and custom usage?
I was going to verify myself by turning the preference off, as indicated in the docs, but, surprisingly, I don’t seem to have the preference, even though the short-tag functionality works. (I assume it will appear in stable release soon.)
Could a dev shed some light on the question above. Thanks.
Offline
Re: Short-tags and shortcodes
jakob wrote #310486:
On custom short tags you have a stray
`
in the final code example. On the other pages you have a few attributes with textilised quotes rather than straight quotes.
Thanks, I’ll track those down.
p.
Offline
Re: Short-tags and shortcodes
Destry wrote #310487:
But it got me wondering, is the short-tags preference for core short-tags only, or for both core and custom usage?
Never mind. This is already answered in the doc I edited. lol
See custom short-tags and shortcodes
When the core short-tags preference is disabled, you can still use the output_form
version of the custom short-tag and the shortcodes still work. Ding! Though you would have to change all the tags if preferences ever were turned off, so maybe the smart approach in collaborative sites is to use the output_form
tag for shortcode uses, just in case someone gets preffy-happy.
Offline
Re: Short-tags and shortcodes
One more thing regarding the section on “Shortening tag constructs using negation” at the end of core short tags:
I’m sure I’ve asked this before but can’t find it: I can’t remember whether the not
negates all the given attributes or just the immediately following attribute, i.e. if mixing positive and negative attributes is allowed. Maybe – after clarification from the devs – just add a note to this effect.
I was about to suggest another example for if_variable
and not value=""
as an improvement on if_variable value="" else … do something … if_variable
but then realised it depends on whether you can indeed negate just the value attribute.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Short-tags and shortcodes
Good question. That’s Bloke’s text, I believe, so he’ll need to clarify.
Offline
Re: Short-tags and shortcodes
jakob wrote #310492:
I can’t remember whether the
not
negates all the given attributes or just the immediately following attribute, i.e. if mixing positive and negative attributes is allowed. Maybe – after clarification from the devs – just add a note to this effect.
It does not negate any attribute (it’s actually impossible to do globally), it just switches true and false parts of the tag content. E.g.
<txp:variable name="yesno" value="yes" />
<txp:if_variable name="yesno" value="yes">YES!<txp:else />NO!</txp:if_variable>
outputs YES!
, but
<txp:variable name="yesno" value="yes" />
<txp:if_variable not name="yesno" value="yes">YES!<txp:else />NO!</txp:if_variable>
outputs NO!
. You can say it negates the whole combination of attributes, though.
Offline
Offline
Re: Short-tags and shortcodes
etc wrote #310498:
It does not negate any attribute, it just switches true and false parts of the tag content … You can say it negates the whole combination of attributes, though.
Ok, so the end could read:
Using not
negates the result of the entire tag including any combination of attributes it may have. It does not negate individual attributes. This feature also extends to all plugins, natively without any need to do anything by the plugin author.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Short-tags and shortcodes
etc wrote #310501:
I would just suggest you take a look there to see how you could explain the use of
yield
attribute.
I see what you mean. Aside (no pun) from the new (last) section added in that aside-quote doc, I wonder if a more clear explanation of `yield` usage is better suited for the Core short-tags doc (i.e., at the top of the concept pile). Otherwise we run the risk of being redundant in every example page. Better to explain things once and link up to where it’s first explained.
That said, I’m not sure I’m the best person to explain the yield tag thoroughly. I think I was lucky to get the aside-quote shortcode to even work. ;)
Offline
Re: Short-tags and shortcodes
Destry wrote #310508:
I’m not sure I’m the best person to explain the yield tag thoroughly. I think I was lucky to get the aside-quote shortcode to even work. ;)
For the record, its birth name was txp-yield
and I didn’t think to expose it at all. This was a “finetune” attribute awaiting a better solution. But then I thought of forms named like Contact Form
and the likes. You can not evoke it as shortcode: <txp::Contact Form />
is ambiguous. But you still can pass it <txp:yield />
attributes if you wish, with
<txp:output_form yield form="Contact Form" id="12" name="Joe" ... />
Things are still moving and any feedback is invaluable.
Offline