Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-03-30 22:54:07

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

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…

  1. The extra eyes on changes would be nice in case it’s flat wrong (advancing the copy of others before me) or undecipherable.
  2. You might want to know about this cool new feature.

I’ll let the docs do the talking:

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

#2 2018-03-31 10:40:12

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

#3 2018-03-31 10:47:57

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

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

#4 2018-03-31 10:50:41

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

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

#5 2018-03-31 10:55:21

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

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

#6 2018-03-31 11:03:47

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

#7 2018-03-31 11:33:08

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

Re: Short-tags and shortcodes

Good question. That’s Bloke’s text, I believe, so he’ll need to clarify.

Offline

#8 2018-03-31 12:24:27

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

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

#9 2018-03-31 12:35:02

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

Re: Short-tags and shortcodes

Nice write-up, Destry, very useful! I would just suggest you take a look there to see how you could explain the use of yield attribute.

Offline

#10 2018-03-31 13:47:13

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

#11 2018-03-31 14:13:08

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

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

#12 2018-03-31 14:29:27

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

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

Board footer

Powered by FluxBB