Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2017-04-21 13:49:32

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355

Re: Shortcodes (as seen in rah_beacon)

etc wrote #305435:

<txp:output_form form="media_video" width="640" height="480" ratio="0.5625" mp4-url="/video/video.mp4" webm-url="/video/video.webm" poster-url="/img/poster.png" duration-seconds="20" />...

+1

…..

<txp:output_form form="someform" anyname1="somevariable" anyname2="qwerty" />

someform:

...define defaults
<txp:yield_default  anyname1="11" anyname2="22"  />
.
...set/override yield
<txp:yield name="anyname1" value="33" />  or <txp:yield name="anyname1">33</txp:yield>
.
...use yield
<txp:yield name="anyname1" />
<txp:yield name="anyname2" />
.
...if
<txp:if_yield name="anyname1">
..
<txp:else />
..
</txp:if_yield>
<txp:if_yield name="anyname2" value="qwerty">
..
</txp:if_yield>

aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#17 2017-04-21 13:57:21

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

Re: Shortcodes (as seen in rah_beacon)

NicolasGraph wrote #305439:

Interesting thread; would it be possible to add a value or default attribute to <txp:yield /> to provide a default value?

Yes, currently it’s the content:

<txp:yield name="test">default value</txp:yield>

I also like makss idea: <txp:yield name="test" value="default value" />.

Offline

#18 2017-04-21 14:02:30

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,566
Website GitHub Mastodon

Re: Shortcodes (as seen in rah_beacon)

Again, as long as the default values of yield can be within the form itself, I’m super happy! Probably favouring Makss idea of yield syntax – although does a container tag provide more options for content? Dunno.

Offline

#19 2017-04-21 14:45:30

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

Re: Shortcodes (as seen in rah_beacon)

philwareham wrote #305442:

Probably favouring Makss idea of yield syntax – although does a container tag provide more options for content?

Nothing to stop us providing both, like we do with the form attribute in other tags at present. Container overrides value, probably, in the same way as container overrides form in other tags?


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

#20 2017-04-21 16:00:44

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Shortcodes (as seen in rah_beacon)

Bloke wrote #305443:

Nothing to stop us providing both […]

That would be nice and introduce some consistency with <txp:variable />.


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#21 2017-04-21 18:17:33

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

Re: Shortcodes (as seen in rah_beacon)

Ok, let have both. Also, should <txp:output_form form="some_form" wraptag="p" /> consider wraptag as global attribute, or as <txp:yield name="wraptag" /> (current case)?

Offline

#22 2017-05-03 11:48:29

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

Re: Shortcodes (as seen in rah_beacon)

etc wrote #305445:

Ok, let have both.

I love this feature. After reviewing a tonne of off-the-shelf software out there for delivering topic-based documentation, I’ve tentatively started using (a plugin-customised) Txp for it instead, and this feature is fabulous for parameterizing reusable Forms.

should <txp:output_form form="some_form" wraptag="p" /> consider wraptag as global attribute, or as <txp:yield name="wraptag" /> (current case)?

Whichever offers the user the fewest surprises. I would be tempted to say that it should wrap the entire content, in the same way that any other wraptag/class combo does in Txp. If someone wants a different wraptag for the yield, they should add the attribute to that tag. Unless I’ve missed some subtle nuance here.


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

#23 2017-05-04 09:25:23

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

Re: Shortcodes (as seen in rah_beacon)

Bloke wrote #305587:

I would be tempted to say that it should wrap the entire content, in the same way that any other wraptag/class combo does in Txp. If someone wants a different wraptag for the yield, they should add the attribute to that tag. Unless I’ve missed some subtle nuance here.

No, it’s only semantics. A yield called class looks more natural than my_class.

Edit: also, global attributes set being plugin-extensible, a form yield attribute can inadvertently become global.

Offline

#24 2017-05-04 09:59:37

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

Re: Shortcodes (as seen in rah_beacon)

etc wrote #305616:

A yield called class looks more natural than my_class.

Ah yes, allowing arbitrary attributes for the output_form tag opens the possiblity of clashes with global attributes. Hadn’t thought of that. Hmmm…


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

#25 2017-06-20 08:03:42

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,670
Website

Re: Shortcodes (as seen in rah_beacon)

@etc

Oleg, now that you have fully enabled short-tags, one-and-half Q’s …

1/ Is it expected that the form name can’t contain hyphens? I was testing this out today. The following works fine:

<txp:output_form form="xyz-image" id="xx" />

but the equivalent fails (silently):

<txp::xyz-image id="xx" />

rename the form to xyz_image works.

2/ In your checkin, I see you added a reset attribute to the @<txp:yield /> tag, if I understand the code correctly. Can you explain the usage? (like philwareham upthread, I had so far not much understanding of that tag, I need to add).


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

#26 2017-06-20 08:43:39

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

Re: Shortcodes (as seen in rah_beacon)

phiw13 wrote #306044:

@etc

Oleg, now that you have fully enabled short-tags, one-and-half Q’s …

This half-ready commit is a bit forced, I was not able to sync with dev otherwise. The work continues, so don’t yet rely on it too much.

1/ Is it expected that the form name can’t contain hyphens? I was testing this out today. The following works fine:

<txp:output_form form="xyz-image" id="xx" />...

but the equivalent fails (silently):

<txp::xyz-image id="xx" />...

rename the form to xyz_image works.

Historically (before 4.6), <txp:abc_tag /> was internally transformed into abc_tag() function call. Since abc-tag is not a valid function name, hyphens were forbidden. Now we can allow them, but it would require more discipline re tag registration. Not sure about it…

2/ In your checkin, I see you added a reset attribute to the @<txp:yield /> tag, if I understand the code correctly. Can you explain the usage? (like philwareham upthread, I had so far not much understanding of that tag, I need to add).

It’s still in work, it seemed useful to me, but now I don’t remember how :-)

Edit: and many thanks for testing, btw!

Offline

#27 2017-06-20 09:08:03

phiw13
Plugin Author
From: South-Western Japan
Registered: 2004-02-27
Posts: 3,670
Website

Re: Shortcodes (as seen in rah_beacon)

etc wrote #306045:

This half-ready commit is a bit forced, I was not able to sync with dev otherwise. The work continues, so don’t yet rely on it too much.

Right, just playing with it on the local server , exploring possibilities. Sure it offers possibilities to optimise my forms used to insert images, etc in the body of an article.

Historically (before 4.6), <txp:abc_tag /> was internally transformed into abc_tag() function call. Since abc-tag is not a valid function name, hyphens were forbidden. Now we can allow them, but it would require more discipline re tag registration. Not sure about it…

Oh, now that you mention it, I remember that limitation. I’m fine with it; probably just need documenting when those short-tags are finalised.

It’s still in work, it seemed useful to me, but now I don’t remember how :-)

Edit: and many thanks for testing, btw!

:-)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
phiw13 on Codeberg

Offline

Board footer

Powered by FluxBB