Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Post your Short-Tags
Short-tags were introduced on txp v4.7 and although I was initially worried about the learning curve, it proved to be really easy. I just thought that it would be good if people posted some of their short-tags here for some cross-fertilisation of ideas.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Post your Short-Tags
Short-tag for vimeo which includes a GDPR cookie acceptance.
<txp:if_yield name="setcookie" value="1"><txp:oui_cookie name="accept_vimeo_cookies" duration="+1 year" values="yes" /></txp:if_yield>
<txp:oui_if_cookie name="accept_vimeo_cookies">
<div class="embed-container"<txp:if_yield name="id"> id="<txp:yield name="id" />"<txp:else /> id="vids"</txp:if_yield>><txp:linklist category='<txp:yield name="cat" />' limit="100" sort="id asc" form="" wraptag="div" class="slider"><div class="slide"><div class="embed-container"><iframe src="https://player.vimeo.com/video/<txp:link_description escape="" />?title=0&byline=0&portrait=0" allowfullscreen></iframe></div></div></txp:linklist></div>
<txp:else />
<div class="vimeoeucookies noprint"><p class="centre">We would very much like you to watch these <txp:if_yield name="other"><txp:yield name="other" /><txp:else />NeMe produced</txp:if_yield> videos, <txp:yield name="txt" wraptag="presenting <+>" />, and they are hosted by Vimeo on <txp:linklist category='<txp:yield name="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>.<br />By viewing them here, you accept Vimeo's <a rel="external" href="https://vimeo.com/privacy">privacy policy</a>.</p><p class="red centre"><a rel="nofollow" href="?accept_vimeo_cookies=yes<txp:if_yield name="id">#<txp:yield name="id"/></txp:if_yield>">View them here</a></p><p>Note that Vimeo only serves First Party cookies in embedded videos but acording to their <a rel="external" href="https://vimeo.com/cookie_policy">cookie policy</a>, more are used in their website.</p></div></txp:oui_if_cookie>
And the tag
<txp::vimeo id="vid" video="xxx" txt="yyy" setcookie="1" />
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Post your Short-Tags
colak wrote #312522:
Short-tag for vimeo which includes a GDPR cookie acceptance. […]
Thanks colak, I guess that providing an example of this form used a custom shortag would make the use of attributes easy to understand.
…and you could also use core short tags, right?
<if::yield name="setcookie">
<oui::cookie name="accept_vimeo_cookies" duration="+1 year" values="yes" />
…
Last edited by NicolasGraph (2018-06-12 09:52:08)
Offline
Re: Post your Short-Tags
Hi Nicolas,
I have to admit that I am yet to start using core short-code but from your example, it does indeed save some typing.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Post your Short-Tags
Short-tag for Vimeo OR YouTube videos with GDPR cookie acceptance
<txp:if_yield name="setcookie"><oui::cookie name='accept_<txp:yield name="provider" />_cookies' duration="+1 year" values="yes" /></txp:if_yield>
<txp:hide>This sets the cookie and it is required just once/provider/article</txp:hide>
<oui::if_cookie name='accept_<txp:yield name="provider" />_cookies'>
<div class="embed-container"<txp:if_yield name="id"> id="<txp:yield name="id" />"</txp:if_yield>>
<txp:if_yield name="provider" value="vimeo">
<iframe src="https://player.vimeo.com/video/<txp:yield name="video" />?title=0&byline=0&portrait=0" allowfullscreen></iframe>
</txp:if_yield>
<txp:if_yield name="provider" value="youtube">
<iframe src="//www.youtube.com/embed/<txp:yield name="video" />?rel=0" frameborder="0" allowfullscreen></iframe>
</txp:if_yield>
</div>
<txp:else />
<div class="nocookies noprint">
<txp:if_yield name="provider" value="vimeo">
<p class="centre">This video, <txp:yield name="txt" wraptag="presenting <+>" /> is hosted by Vimeo on <a rel="external" href="https://vimeo.com/<txp:yield name="video" />">vimeo.com/<txp:yield name="video" /></a></txp:if_yield>. By viewing it here, you accept Vimeo's <a rel="external" href="https://vimeo.com/privacy">privacy policy</a>.</p><p class="red centre"><a rel="nofollow" href="?accept_vimeo_cookies=yes<txp:if_yield name="id">#<txp:yield name="id" /></txp:if_yield>">View</a></p>
</txp:if_yield>
<txp:if_yield name="provider" value="youtube">
<p class="centre">This video, <txp:yield name="txt" wraptag="presenting <+>" /> is hosted by Youtube on <a rel="external" href="https://www.youtube.com/watch?v=<txp:yield name="video" />">youtube.com/watch?v=<txp:yield name="video" /></a></txp:if_yield>. By viewing it here, you accept Youtube's <a rel="external" href="https://www.youtube.com/intl/en-GB/yt/about/policies/">privacy policy</a>.</p><p class="red centre"><a rel="nofollow" href="?accept_youtube_cookies=yes<txp:if_yield name="id">#<txp:yield name="id" /></txp:if_yield>">View</a></p>
</txp:if_yield>
</div>
</oui::if_cookie>
Sample short-tag
<txp::video id="vid" provider="vimeo" video="xxx" txt="yyy" setcookie="" />
> Edit: Thanks, Nicolas and Oleg. Changed the code.
Last edited by colak (2018-06-12 16:21:30)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Post your Short-Tags
Another possible shortcut:
<txp:yield name="txt" wraptag="presenting <+>" />
instead of
<txp:if_yield name="txt">presenting <txp:yield name="txt" /></txp:if_yield>
Offline
Re: Post your Short-Tags
Links with rel attribute
<a href="<txp:yield name="url" />"<txp:if_yield name="rel"> rel="<txp:yield name="rel" /></txp:if_yield>"><txp:if_yield name="txt"><txp:yield name="txt" /><txp:else /><txp:yield name="url" /></txp:if_yield></a>
Sample tag
<txp::link url="https://textpattern.com/" rel="external" txt="Love Textpattern" />
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Post your Short-Tags
I think all of those <txp:if_yield />
tags can be written as:
<if::yield />
<if::yield> ... </if::yield>
Saves you 3 characters each time.
Just depends how far you care to venture into the woods before it gets too abstract and scary.
Offline
Pages: 1