Mwebvendor
can i use xtcat counters in a blog list?
Aash
Mwebvendor yes, Graham will answer you
Graham
Mwebvendor I have not tried them in blog
I am away from my pc till friday
I will look into it when I get back home
Graham
Mwebvendor it turns out to be surprisingly easy
If your blog is assigned to a xtscript variable and then printed
You can add xt:widgets and xt:functions directly into the twig as xtscript changes the parsing order
this code goes in
{% block entries_list %} somewhere inside the '
{% for entry in data.entries %} loop to display the counters without updating them
{%set xtcat=entry.url|split('__xtblog_entry/')%}
{%set xtcat=xtcat[1]|split('?')%}
<span class="xt_button"><xt:widget tool="Counter" site="SITE" type="display1" idstring="{{xtcat[0]}}" key="XTCAT KEY" xtuser="XTCAT USER" id="xt.c.a.t." /></span>
Copy code
This code goes somewhere in
{% block entry_post %} to display the count and update it
{%set xtcat=data.post.url|split('__xtblog_entry/')%}
{%set xtcat=xtcat[1]|split('?')%}
<span class="xt_button"><xt:widget tool="Counter" site="SITE" idstring="{{xtcat[0]}}" key="XTCAT KEY" xtuser="XTCAT USER" id="xt.c.a.t." /></span>
Copy code
demo
http://adgj.mw.lt/blog_0
In the demo I also used a gradient text widget to display the post titles
so the same method should work for other widgets
I dont think it will work in forum as that is not available to xtscript
Remember to set your own site user and key in the above code and it will only work via xtscript
Use this trick to set the blog so you can still use it in the building tool
<!--parser:xtscript-->
# </xt:code>
var $blog=<xt:blog tzone="0" format="Y-m-d" display="1" show_time="0" entries_per_page="10" 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>
print $blog
<!--/parser:xtscript-->
Copy code
Graham
Mwebvendor To see exactly what is available in the data array of a blog on any blog page
add this at the top of your twig
<textarea>{{ data|json_encode(constant('JSON_PRETTY_PRINT')) }}</textarea>
Copy code
Mwebvendor
Thank for our graham..
comment my coming soon blog .. BAD or GOOD.
http://workpage.xtgem.com/videos
Graham
So that xtscript $variables and brackets are not parsed in users comments you need to add this filter
|replace({'(': '\\(', '$': '\\$'})
in the
{% macro comments_list (comments, ctx) %} near the end of the macro where the comments are output (2 places)
<div class="xt_blog_comment_content">{{ comment.message|replace({'(': '\\(', '$': '\\$'})|raw }}</div>
Copy code
Note you may also see these problems in your posts so you May need to add the filters there as well
or if you wish escape them in the post code