This script creates a list of specified blog categories (tags) with counts of the posts in the category
it is created using a combination of twig xtscript and javascript it is styled using Bootstrap (plus some custom javascript)
The Twig
Rename your xtblog.twig to blog.twig then create a new xtblog.twig file and copy this code to it
some users may already have a 'template selector' xtblog.twig so you can add this as a {% elseif %} before the standard blog twig is included
The XtScript
There is no direct output from this script it can go anywhere in your pages code
The variable $data holds a list of the tags you wish to use as categories separated by pipe symbols ( | )
The script creates the list of tag links and the javascript calls to insert the post counts
It also inserts the active bootstrap class in the current item
The HTML
Put this where you wish the list to appear it uses bootstrap nav collapse to hide the panel on smaller screens and some custom javascript to switch the text on the open /close button
The actual list is inserted using a xtscript variable {_$$categories|} The Javascript
This can go anywhere below the html
The first function switches the text on the open/close button (only shows on small screens)
The second function uses XHR javascript to retrieve the post counts for each tag
I used this method so that the blog calls will not cause conflicts as they are actually on a seperate page The XmlHttpRequest Data File
This is used to generate the post counts for each tag
add this to a blank text file named catdata
(Only edit this file using the text editor)