* Inu Kode TWIG buat random posting di xtblog....?
2015-03-20 00:14 · (0)
* TechnoSparks * Inu Graham would not able to understand you. You should use english instead.

Graham, he requested you to show a twig code that changes the behaviour of the blog block to show random posts rather than an arranged list. :)
2015-03-21 01:07 · (0)
* Graham * Inu it translates as "TWIG code for a random post on xtblog"
if you wish to show ONE random post instead of the list
in the blog twig block {% block entries_list %}
remove the line {% for entry in data.entries %}
and replace it with
{%set entry=data.entries[(random(data.entries|length-1))] %}
Copy code

and remove the corresponding {% endif %}
you will need to set your blog function to entries_per_page="0" to use the whole post list
As this is set in the twig ALL blog functions on the site will be affected the same
This is where I have tested it http://blogtwig.xtgem.com/blag
2015-03-21 01:48 (edited 2015-03-21 01:57 by Graham ) · (1)
* Inu * Graham thanks graham, and how to set the <meta name = automatically on every post in xtblog ....?
2015-03-25 16:54 · (0)
* Inu * TechnoSparks Thanks bro .. Already explain :)
2015-03-25 16:57 · (0)
* Graham * Inu Which meta tags ? and set to which part of the posts content?
It needs to use xtscript
2015-03-26 02:21 (edited 2015-03-26 02:22 by Graham ) · (0)
* Inu * Graham yes meta tag .. set to _headertags part .... It may show the code ..
2015-03-26 04:59
*
* UC Super MOD V5-20-59-56.png · image/png · 14.4KB
· (0)
* Graham * Inu This is a complete page code
It now takes the contents of the post up to the first </div>
You can still use the blog on the page from the building tool just be careful of the other lines
disable any other description meta tag the new tag is inserted by {_$$meta|}
<!DOCTYPE html>
<html>
<head>
  {_$$meta|}
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>x</title>
</head>
<body>
    <div data-xtcontainer="container" class="xt_container"><xt:code><!--parser:xtscript-->
    # </xt:code>
  var $blog=<xt:blog tzone="0" format="Y-m-d" display="1" show_time="0" entries_per_page="3" 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>
      var $start_post_content = call strpos $haystack=$blog;$needle=xt_blog_content xt_text normal
      if $start_post_content >0
      var $start_post_content =($start_post_content+32)
      var $end_post_content = call strpos $haystack=$blog;$needle=</div>;$offset=$start_post_content
      var $post_content = call substr $val=$blog;$start=$start_post_content;$length=($end_post_content-$start_post_content)
      var $cleaned_post_content=call strip_tags $val=$post_content
      var $meta=<meta name="description" content="$cleaned_post_content" />
      endif

    print $blog
    del $blog
assign $dump=call dump_vars
assign $dump=call trim $val=$dump ; $charlist={{<pre>
Array/ }}
assign $dump=call trim $val=$dump ; $charlist=( )
assign $dump=call htmlspecialchars $val=$dump
assign $dump=call nl2br $val=$dump
print $dump<br/>
    <!--/parser:xtscript--></xt:code>
    </div>
</body>
</html>

Copy code
2015-03-26 06:11 (edited 2015-03-26 14:55 by Graham ) · (0)
* Inu * Graham Xtscript you give do not succeed ... Demo http://streetfilm.sextg em.com/view/
2015-03-26 10:31
* * *
* UC Super MOD V5-2-30-04.png · image/png · 14.78KB
* UC Super MOD V5-2-30-14.png · image/png · 14.51KB
* UC Super MOD V5-2-30-28.png · image/png · 15.67KB
· (0)
* Graham * Inu I have changed the code below
open a post
It now takes the contents of the post up to the first </div>
It then passes it through striptags and uses the result in the description meta tag
This is based on standard twig on a version 2 blog with html enabled in the post
the demo includes a variable dump at thebottom of the page
http://newblogtest.yn.lt/blog
2015-03-26 14:44 (edited 2015-03-26 14:59 by Graham ) · (0)

Online: Guests: 1