* Graham I have created a tool that displays a panel showing the online users and which boards have unread posts in them
I could not go down to individual posts level as the data is just not available
(you only get the data available on the forum 'home' page)
Basically you wrap the entire contents of xtforum.twig in a {% if %} statement
and control it from a set of variables in the translate file
Add a <xt:forum /> function on any page not set in the show_forum_paths variable and the online and new posts panels show instead
all the files are available from the forum page on http://baretest.xtgem.com
this version uses standard bootstrap 3.37 classes
NOTE: it will not work correctly until you have at least 2 boards or categories
coding for single board forums would have doubled the size of the code and was just not worth it
these are the control variables set in _xtgem_translations /xtforum
// ONLINE AND UNREAD BOARDS WIDGET
// Turn the feature on (1) or off (0)
online_unread= 1
// New posts panel title
title_new_posts=New posts in these forum boards
// Url of main forum page
forum_path=/forum
// Show full forum on these pages 
// start paths with ./ 
// 'index' files must be named in paths
// separate paths with spaces
show_forum_paths=./forum ./folder/index

Copy code

this goes at the top of xtforum.twig
{# Online users and unread boards #}
{% set path='./'~current_url|split('/__')[0]|split('/',4)[3] %}
{% if __view=='categories' and  path not in translate ( 'show_forum_paths' ) and translate ( 'online_unread' )=='1'  %}
  </div>
</div>
<div class="panel-group">
  <div class="panel panel-default">
    <div class="panel-heading"> {{translate('online') }} </div>
    <div class="list-group">
{% if online_users%}
      <div class="list-group-item">   
  {% for user in online_users %}
        <a class="btn btn-default btn-xs" href="{{ user.link }}" title="{{ translate ( 'view_user_profile', user.name ) }}">{% if profile.name==user.name %}<img class="" alt="-" src="{{ profile.avatars[16] }}" /> {% endif %}{{ user.name }}</a>
  {% endfor %}
      </div>
{% endif %}
{% if settings.show_counter and online_guests > 0 %}
      <div class="list-group-item">{{ translate ( 'guests' ) }}: {{ online_guests }}</div>
{% endif %}
{% set heading = 0 %}
{% for category in categories %}
  {% for board in category.boards %}
    {% if not board.read %}
      {% if not heading %}
        {% set heading = 1 %}
    </div>
  </div>
  <div class="panel panel-default">
    <div class="panel-heading">{{translate('title_new_posts')}}</div>
    <div class="list-group">
      {%endif%}
      {% set _online = get_online ( '/category_' ~ category.id ~ '/board_' ~ board.id  ) %}
      <a class="list-group-item" href="{{ board.link|replace({(path|split('.',2)[1]):translate ( 'forum_path' )}) }}" title="{{ board.title }}">{{ board.title }} {% if _online > 0 %}<small class="badge">{{ _online }}</small>{% endif %}<span class="badge"> {{board.threads_count}}/{{board.posts}}</span></a> 
    {%endif%}
  {%endfor%}
{%endfor%}
{% if translate ('debug')=='1'%}<div class="list-group-item">Categories<textarea class="form-control" style="">{{ categories|json_encode(constant('JSON_PRETTY_PRINT')) }}</textarea>Online users<textarea class="form-control">{{ online_users|json_encode() }}</textarea>Profile<textarea class="form-control">{{ profile|json_encode(constant('JSON_PRETTY_PRINT')) }}</textarea>Path='{{path}}'</div>{%endif%}
    </div>
  </div>
</div>
<div style="display:none"><div>
{%else%}

Copy code

and you have to add a
{%endif%}
at the end of the file
2017-02-08 02:53 (edited 2017-02-09 04:10 by Graham ) · (2)
* Ekonime thanks sir :)
2017-02-08 12:05 · (0)

Online: Guests: 1