Version 1.3.1-beta
Release date 01.21.2019
Downloads 1 408
Views 4 041
Warning! This component requires PHP version 5.4 or higher! If your site uses PHP less than required, the installation of this package could break it.
Warning! This package requires MODX not less than 2.3 !


It is a TV field where we can enter values «on the go». In other words, we do not specify «Possible Values» while editing the TV but enter those values into that field on the resource edit page. It is very convenient to use such a field to create tags on a website, because, apart from adding values «on the go», we can also choose values already used from other resources.


 TVSSResources Snippet


The snippet displays tagged resources. All its parameters are usable in pdoFetch, which makes it possible to specify any pdoTools parameters… It understands Fenom and can work with pdoPage. The following example presents a selection of resources with «tag1», «tag2», and «tag3», specified in the TV with IDs 17 or 19:

<code>{$_modx->runSnippet('pdoPage', [
    'element' => 'tvssResources',
    'tv' => '17,19',
    'tag' => 'tag1||tag2||tag3',
    'parents' => 0,
    'tpl' => '@INLINE</code>


{$id} — {$pagetitle}

',
])}
{$_modx->getPlaceholder('page.nav')}
 The tags can be specified as a parameter in the snippet or as a «tag» parameter in a GET query. The snippet redefines the above tag in the GET query.


TVSSTickets Snippet


The snippet displays all tagged tickets of the Ticket extra. All its parameters are usable in getTickets, which makes it possible to specify any getTickets parameters. The following example presents tickets with tags «tag1», «tag2», and «tag3», specified in the TV with IDs 17 or 19:

{$_modx->runSnippet('pdoPage', [
    'element' => 'tvssTickets',
    'tv' => '17,19',
    'tag' => 'tag1||tag2||tag3',
    'parents' => 0,
])}
{$_modx->getPlaceholder('page.nav')}
 The tags can be specified as a parameter in the snippet or as a «tag» parameter in the GET query. The snippet redefines the above tag i the GET query. 


TVSSTags Snippet


Displays a list of resource tags. Example of displaying all tags from TV field 17, specified in the current resource. A URL for Resource 2 (where the tvssResources snippet is) is created in a tag reference:

{$_modx->runSnippet('tvssTags', [
    'id' => $_modx->resource.id,
    'tv' => 17,
    'pageId' => 2,
])}
The list of parameters also includes tpl, tplWrapper, outputSeparator, and toPlaceholder. 


Tag Creation Guide for a Website


Attention! This guide is written using Fenom. If you do not use it on your website, you will have to entirely change the code in the examples to standard syntax.


  1. After the extra has been installed, create a new TV using tvSuperSelect. Memirize its ID (in our case, it is 2).
  2. Create the resource "Tagged Resources". Memorize its ID (in our case, it is 2). Write down the following in the longtitle:
    Tagged resources {$.get['tag'] ? ' «'~($.get['tag']|unescape:"url")~'»' : ''}
    • Content for displaying a list of resources:
      {if $.get['tag']?}
          <div id="pdopage">
              <div class="rows">
                  {$_modx->runSnippet('pdoPage', [
                      'element' => 'tvssResources',
                      'tv' => '2',
                      'parents' => 0,
                      'ajaxMode' => 'default',
                      'tpl' => '@INLINE <div>{$id} - {$pagetitle}</div>',
                  ]) ?: 'No resources for this tag found'}
              </div>
              {$_modx->getPlaceholder('page.nav')}
          </div>
      {else}
      Specify tag for documents selection
      {/if}
    • Content for displaying a list of tickets:
      {if $.get['tag']?}
          <div id="pdopage">
              <div class="rows">
                  {$_modx->runSnippet('pdoPage', [
                      'element' => 'tvssTickets',
                      'tv' => '2',
                      'parents' => 0,
                      'ajaxMode' => 'default',
                  ]) ?: 'No tickets for this tag found'}
              </div>
              {$_modx->getPlaceholder('page.nav')}
          </div>
      {else}
      Specify tag for documents selection
      {/if}
  3. Specify tag list display in the template (or chunk) displaying a complete article or ticket:
    {$_modx->runSnippet('tvssTags', [
        'id' => $_modx->resource.id,
        'tv' => 2,
        'pageId' => 2,
    ])}

A Guide for Displaying Similar Articles Using Tags


  • Similar Resources

    Fenom:
    {$_modx->runSnippet('tvssResources', [
        'tv' => '2',
        'tags' => $_modx->runSnippet('tvssTags', ['id' => $_modx->resource.id, 'tv' => '2', 'tpl' => '@INLINE [[+tag]]', 'outputSeparator' => '||']),
        'parents' => 0,
        'limit' => 4,
    ]) ?: 'No similar entries found'}
    Standard syntax:
    [[tvssResources:empty=`No similar entries found`?
        &tv=`2`
        &tags=`[[tvssTags?id=`[[*id]]`&tv=`2`&tpl=`@INLINE [[+tag]]`&outputSeparator=`||`]]`
        &parents=`0`
        &limit=`4`
    ]]

     


  • Similar Tickets

    Fenom:
    {$_modx->runSnippet('tvssTickets', [
        'tv' => '2',
        'tags' => $_modx->runSnippet('tvssTags', ['id' => $_modx->resource.id, 'tv' => '2', 'tpl' => '@INLINE [[+tag]]', 'outputSeparator' => '||']),
        'parents' => 0,
        'limit' => 4,
    ]) ?: 'No similar entries found'}
    Standard syntax: 
    [[tvssTickets:empty=`No similar entries found`?
        &tv=`2`
        &tags=`[[tvssTags?id=`[[*id]]`&tv=`2`&tpl=`@INLINE [[+tag]]`&outputSeparator=`||`]]`
        &parents=`0`
        &limit=`4`
    ]]

A Few Details on Values Database Storage

  1. This TV field has a tvss_options table of its own where data are stored as follows:
  2. The data are, however, also stored in a site_tmplvar_contentvalues table, but as a JSON array:

The former is intended for convenient filtering; the latter, for simple displaying. Discuss the extra in MODX.PRO community.

1.3.1-beta (21.01.2019)

  • Исправлен тип колонки tv_id на int в схеме базы данных

1.3.0-beta2 (05.11.2018)

  • Поправлено формирование имени ТВ поля

1.3.0-beta (28.10.2018)

  • Добавлена поддержка MIGX

1.2.2-beta (13.09.2018)

  • Добавлено поле display в ComboBox для разделения отображаемого текста и значения

1.2.1-beta (13.09.2018)

  • Добавлен параметр context_key, передаваемый в процессор

1.2.0-beta (12.09.2018)

  • Добавлена возможность указать ТВ свой коннектор и процессор для вывода кастомных значений

1.1.7-beta (15.12.2017)

  • Поправлены предупреждения в сниппете tvssResources и tvssTickets

1.1.6-beta (03.06.2017)

  • Поправлены баги в сниппете tvssResources и tvssTickets

1.1.5-beta2 (24.04.2017)

  • Корректировки сниппета tvssCloud

1.1.5-beta (24.04.2017)

  • Сниппет tvssCloud

1.1.4-beta (07.12.2016)

  • Поправлена работа с товарами miniShop2 >=2.4
  • Рефакторинг кода плагина

1.1.3-beta (17.06.2016)

  • В сниппеты tvssResources и tvssTickets добавлен параметр &like, который отвечает за способ выборки. Если указан &like=`1`, то при выводе ресурсов по тегу "еда", в результаты будут добавлены ресурсы с тегом "педагог". Если же &like=`0`, то поиск по тегам осуществляется точный. По-умолчанию &like=`0`.

1.1.2-beta2 (07.06.2016)

  • Поправлен баг с удалением данных из таблицы tvssOption при полной очистке поля

1.1.2-beta (19.03.2016)

  • В сниппетах tvssResources и tvssTickets поправил warnings в журнал ошибок
  • Поправлен косяк с кривым отображением input

1.1.1-pl3 (18.03.2016)

  • В tvssTags добавлен параметр &scheme

1.1.1-pl2 (18.03.2016)

  • В сниппетах tvssResources и tvssTickets поправил обработку совмещения параметра &loadModels введённого пользователем

1.1.1-pl (18.03.2016)

  • Восстановлена поддержка PHP 5.3
  • Восстановлена возможность указания пустого &outputSeparator в сниппете tvssTags
  • Добавлен сниппет tvssTickets для вывода списка тикетов (компонент Tickets) по тегу/тегам

1.1.0-pl (17.03.2016)

  • Добавлен сниппет tvssResources для вывода списка ресурсов по тегу/тегам
  • Добавлен сниппет tvssTags для вывода списка тегов ресурса

1.0.1-beta (04.02.2016)

  • Поправлен косяк с кривым отображением кнопок у поля

1.0.0-beta

  • Start