* Graham * Legendishaq
Looking at your site I feel you do not need the full version of the 'related posts' as that creates a random list generated from all the tags on a post and uses a large amount of complex xtscript.
This version lists all the posts linked to the first tag associated with a post and uses no xtscript just twig and some javascript

First rename xtblog.twig to blog.twig and create a new xtblog.twig file with this code
Note: This is just the basic code to create the links
If you wish the links displayed in a certain way (like in a table) I can help you with that
{% if data.post.tags and view='entry' %}<i id="tag" style="display:none">{{  data.post.tags[0].name|default(0) }}</i>{% endif %}
{% if data.translations.t_no_entries_found == 'related'%}
<!--data-->
{% for entry in data.entries %}
{% if data.translations.t_name not in (entry.url|split('?')[0])%}
<a class="my_links" href="{{ entry.url|replace({(data.translations.t_comment):data.translations.t_post})|split('?')[0]~'&__xtblog_block_id=1#xt_blog'}}">{{ entry.title }}</a>
{% endif %}
{% endfor %} 
<!--data-->
{%else%}
{%include 'blog.twig'%}
{%endif%}

Copy code
Add this line where the 'related post' links are to show
Note:You can add this in the blog.twig file below {% block entry_post %} or even in the normal html code for your blog page if you wish
<div id="related" style="display:none"><!----></div>
Copy code
Next add this block of javascript to your blog page anywhere below the blog function
<script>
  function related(url,cFunction) {var xhttp;xhttp=new XMLHttpRequest();xhttp.onreadystatechange = function() {if (this.readyState == 4 && this.status == 200)cFunction(this)}; xhttp.open("POST",url, true);xhttp.send();}
  function getTag(xhttp){document.getElementById('related').innerHTML =xhttp.responseText.split('<!--data-->')[1];document.getElementById('related').style.display = 'block'; }
    var dataPage='/related';
    var entry='{_$__xtblog_entry|0}';
    if (entry !=0){ 
      var tag = document.getElementById('tag').innerHTML;
      if (tag !=0){
        var url=dataPage+'?__xtblog_tag='+tag+'&entry='+entry+'&path=<xt:url type="path" />&datapage='+dataPage;
        related(url, getTag);      }
    }
</script>

Copy code
Finally create a new blank text file named related and add this code
This file just holds the blog function used by the javascript to create the links and is coded to be invisible to search crawler bots
Note: do not edit this file with the building tool only use the code editor
<!DOCTYPE html>
<html style="display:none">
  <meta name="robots" content="noindex" />
  <xt:blog t_no_entries_found="related" t_name="{_$entry|}" t_comment="{_$datapage|}" t_post="{_$path|}"/> 
</html>

Copy code
2018-05-11 12:24 (edited 2018-05-14 10:24 by Graham ) · (0)

Online: Guests: 1