Login
·
Signup
Home
»
XtGem
»
Coding help
»
random blog post list entry
» View post
Graham
This will output a random blog post list entry
This is for version 2 blogs you can add your language settings etc into the blog function
<!--parser:xtscript--> var $blog=<xt:blog entries_per_page="999" display="5" version="2"/> get __xtblog_entry if not $__xtblog_entry var $last_post=call strrpos $haystack=$blog;$needle=xt_item var $random=call mt_rand $min=0; $max=($last_post-12) var $item_start=call strpos $haystack=$blog;$needle=xt_item;$offset=$random var $item_end=call strpos $haystack=$blog;$needle=/div;$offset=$item_start var $item=call substr $val=$blog;$start=($item_start-12);$length=($item_end-$item_start+17) print <div class="xt_blog_parent"> <div class="xt_list"> <div class="xt_blog_post_list">$item</div></div></div> else print $blog endif <!--/parser:xtscript-->
Here is the same code for a version 1 blog
<!--parser:xtscript--> var $blog=<xt:blog entries_per_page="999" display="5" version="1"/> get __xtblog_entry if not $__xtblog_entry var $last_post=call strrpos $haystack=$blog;$needle=xt_blog_title_link var $random=call mt_rand $min=0; $max=($last_post-10) var $item_start=call strpos $haystack=$blog;$needle=xt_blog_title_link;$offset=$random var $item_end=call strpos $haystack=$blog;$needle=</span><br />;$offset=$item_start var $item=call substr $val=$blog;$start=($item_start-10);$length=($item_end-$item_start+17) print <div class="xt_blog" id="xt_blog"> <div class="xt_blog_post_list">$item</div></div> else print $blog endif <!--/parser:xtscript-->
#
2014-03-29 10:07 (edited 2014-03-29 15:09 by
Graham
) ·
(1)
Home
»
XtGem
»
Coding help
»
random blog post list entry
» View post
Online: Guests: 1
Log in