Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[howto] Randomise anything without a plugin
I recently wanted to present some vimeo hosted videos in my site. Vimeo allows us to create albums which are basically a collection of videos presented in one player. The problem is that albums do not play in mobile devices. As the videos were over 30 I thought that loading them all individually would be too much for some devices and as i did not want to make a selection, I was looking for a way to randomly load that content.
In the end the solution was simple as linklist
came to the rescue.
In the link description field I am adding the number of the video as generated by vimeo.
<txp:linklist category="my_link_list_video_category" limit="4" sort="rand()" wraptag="">
<iframe src="http://player.vimeo.com/video/<txp:link_description escape="" />?title=0&byline=0&portrait=0" width="229" height="172" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
</txp:linklist>
Just edited to add that if anybody wishes to use the code for a random quote here’s one html5 suggestion
<txp:linklist category="my_link_list_quotes_category" limit="1" sort="rand()" wraptag="" />
<txp:variable name="linkurl" value='<txp:link_url />' />
<txp:if_variable name="linkurl" value="">
<blockquote><txp:link_description escape="" />
<cite><txp:link_title /></cite></blockquote>
<txp:else />
<blockquote cite="<txp:variable name="linkurl" />"><txp:link_description escape="" />
<footer><a href="<txp:variable name="linkurl" />" rel="external"><txp:link_title /></footer></blockquote>
</txp:if_variable>
</txp:linklist>
Last edited by colak (2013-02-21 16:03:27)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline