Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#11 2017-04-21 13:07:55
- etc
- Developer
- Registered: 2010-11-11
- Posts: 3,410
- Website
Re: Shortcodes (as seen in rah_beacon)
jakob wrote #305433:
yield
would be okay if you can use the name attribute, and the end user (admin writer) doesn’t have to use it (as totally non-intuitive for non-techs).
Sure, end users would just need to say
<txp::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" />
or simply
<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" />
Also important is the ability to define defaults for attributes at the beginning of one’s form.
Like this, rewritten if width
attribute is set?
<txp:yield name="width">640</txp:yield>
And one thing I’ve found one need’s to watch out for is when using a variable of one’s own making inside a form, you need to to reset (or unset) it again at the end of the form or else it will carry over into the next instance. That problem may become less common with oleg’s forthcoming better evaluate options (i.e. obviating the need for using txp:variable to test for certain “has-this”, “is-that” cases), but I’ve yet to fully explore that.
Here I would like an example…
Re namespace again, I prefer short-tag <txp::some_form />
to potentially XML-clashing <output:some_form />
. One of the reasons is also that namespacing implies some (small) performance penalty, and short tags (in 4.7) are optional.
Offline
#12 2017-04-21 13:09:50
- etc
- Developer
- Registered: 2010-11-11
- Posts: 3,410
- Website
Offline
#13 2017-04-21 13:14:07
- philwareham
- Core designer
- From: Farnham, Surrey, UK
- Registered: 2009-06-11
- Posts: 3,215
- Website
Re: Shortcodes (as seen in rah_beacon)
Hi Oleg – I’m happy with your explanations. If this could be coded as an extension of output_form (and also using your short-tag) then I’d be super happy!
Offline
#14 2017-04-21 13:46:53
- etc
- Developer
- Registered: 2010-11-11
- Posts: 3,410
- Website
Re: Shortcodes (as seen in rah_beacon)
Ok, they have landed in dev branch, without short tags and smart yield unsetting atm. This should work, please test:
<!-- create a form called "my_link" -->
<a href="<txp:yield name="href" />" class="<txp:yield name="class">default</txp:yield>"><txp:yield /></a>
<!-- call -->
<txp:output_form form="my_link" href="#">Click me!</txp:output_form>
<!-- should output -->
<a href="#" class="default">Click me!</a>
Offline
#15 2017-04-21 13:47:12
- NicolasGraph
- Plugin Author
- From: France
- Registered: 2008-07-24
- Posts: 860
- Website
Offline
#16 2017-04-21 13:49:32
- makss
- Plugin Author
- From: Ukraine
- Registered: 2008-10-21
- Posts: 355
- Website
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" />...
…..
<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: 3,410
- Website
Re: Shortcodes (as seen in rah_beacon)
NicolasGraph wrote #305439:
Interesting thread; would it be possible to add a
value
ordefault
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: Farnham, Surrey, UK
- Registered: 2009-06-11
- Posts: 3,215
- Website
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: 8,826
- Website
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.
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
Offline