2Hi.Biz
Trang chủ | TWIG | Xtscript | Templates | Xtgem
Random xtblog | Xtgem | Wapmaster - 2Hi.Biz
▼ Random xtblog
* Admin
- Cấp bậc: admin
22-07-2014
demo: http://twig.yn.lt/blogtest

<script type="text/javascript">
          function shuffleArray(array) {
            for (var i = array.length - 2; i > 0; i--) {
              var j = Math.floor(Math.random() * (i + 1));
              var temp = array[i];
              array[i] = array[j];array[j] = temp;}
            return array;}
        </script>
      <!--parser:xtscript-->
      # Note this script will not work in preview
      # some data is urlencoded to protect the building tool layout
        
      # The blog function
      # NOTE entries_per_page Must be 0
      # </xt:code>
      var $blog_list=<xt:blog tzone="0" format="Y-m-d" display="5" show_time="1" entries_per_page="0" comments_per_page="20" comments_sort="-1" entries_sort="-1" display_limit="0" display_symbol="" version="2" t_back_to_posts="" t_comments="" t_comments_empty="" t_post_a_comment="" t_name="" t_comment="" t_post="" t_tags="" t_search="" t_created="" t_showing_tagged_posts="" t_no_entries_found="" t_no_search_results_found="" t_show_all_comments="" t_see_parent_thread="" t_show_all_replies="" t_show_replies="" t_reply="" t_posting_as="" t_comments_login_required="" t_login="" t_signup="" t_confirm_email="" t_report_spam="" /> 
      # <xt:code>
      
      # Number of random posts to display in the list
      var $posts_to_display=5
      
      # Check for post or post list
      get __xtblog_entry
      if not $__xtblog_entry
      
      # Convert the post list into a javascript array
      # Trim data
      var $trim_start=call strpos $haystack=$blog_list;$needle=div class="xt_item"
      var $trim_end=call strrpos $haystack=$blog_list;$needle=span
      var $blog_list=call substr $val=$blog_list;$start=($trim_start-1);$length=($trim_end-$trim_start+6)
      # Remove carriage returns
      var $cr=call urldecode $val=%0A
      var $blog_list=call str_replace $subject=$blog_list;$search=$cr;$replace
      # Remove excess white space
      var $ws=call urldecode $val=++
      var $blog_list=call str_replace $subject=$blog_list;$search=$ws;$replace
      # Separate into array elements
      var $close_div=call urldecode $val=%3C%2Fdiv%3E
      var $blog_list=call str_replace $subject=$blog_list;$search=$close_div;$replace=$close_div','
      var $blog_list='$blog_list$close_div'
      
      # Set up the standard blog post list divs (encoded to protect building tool)
      call urldecode $val=%3Cdiv+class%3D%22xt_blog_parent%22+id%3D%22xt_blog%22%3E%3Cdiv+class%3D%22xt_list%22%3E%3Cdiv+class%3D%22xt_blog_post_list%22%3E
      
      # Output the random post list
      print <script type="text/javascript">var list=[$blog_list]
      print_raw ;var list = shuffleArray(list);for(var i=0;i<
      print $posts_to_display
      print_raw ;i++){document.write(list[i]);}</script>
      
      # Close the post list divs
      print $close_div$close_div$close_div
      
      else
      # Fix a bug in the comment form
      var $blog_list=call str_replace $subject=$blog_list;$search=name="__xtblog_entry" value="";$replace=name="__xtblog_entry" value="$__xtblog_entry" 
      # Output the post
      print $blog_list
      endif
      <!--/parser:xtscript-->
▲ Tổng số: 1
- Share:
BBCode:

Link:
Online: Guests: 1

Từ khóa: Random , xtblog , Random , xtblog