AgelxNash/DocLister

TagSaver: Doclister calls not working

modxuser opened this issue · 3 comments

Could someone help me out please:

I have followed the Forum post as good as I can, but I can't get this working.

My plugin(s) is/are installed and setup properly, the urlencode snippet is installed and the DB tables are being filled up.

Neither of my calls work :(

Call 1 - simply display all of the checked values from a TV in a list

[!DocLister? 
&debug=`1`
&id=`colourscheme_tags` 
&documents=`[*id*]` 
&controller=`site_content_tags` 
&tagsTV=`7` 
&tagsData=`static:[*colourscheme*]` 
&ownerTPL=`@CODE:<ul>[+dl.wrap+]</ul>` 
&tpl=`@CODE:<li>[+tag+]</li>`
!]

In the above call I use "static", I have tried using "get" as well, but neither work

The call could in theory just be called via [*colourscheme_tags*], but that can't be templated, it just outputs a delimeted list separated with a comma, but here there is no space between the comma and the next tag

Using the "DocInfo" snippet renders the same as [*colourscheme_tags*], so no help.

Call 2 - display all of the checked values from a TV in a list and link them to the tag overview page

[!DocLister? 
&debug=`1`
&id=`post_tags` 
&documents=`[*id*]` 
&controller=`site_content_tags` 
&tagsTV=`5` 
&tagsData=`get:[*postTags*]` 
&ownerTPL=`@CODE:<ul>[+dl.wrap+]</ul>` 
&tpl=`@CODE:<li><a href="/[~10~]?tag=[[urlencode? &input=`[+tag+]`]]">[+tag+]</a></li>`
!]

DB Tables

01

02

Thanks in advance :)

Side note: This won't just benefit me, I have started a tutorial for this in English, which can be found here

Steps Taken:

  1. Created DBs via the script in the forum
DROP TABLE IF EXISTS `modx_site_content_tags`;
CREATE TABLE `modx_site_content_tags` (
  `doc_id` int(11) NOT NULL,
  `tag_id` int(11) NOT NULL,
  `tv_id` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`tag_id`,`doc_id`,`tv_id`),
  UNIQUE KEY `dtt` (`doc_id`,`tag_id`,`tv_id`) USING BTREE,
  KEY `doc_id` (`doc_id`),
  KEY `tag_id` (`tag_id`),
  KEY `tv_id` (`tv_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `modx_tags`;
CREATE TABLE `modx_tags` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

  1. Created the "TagSaver" plugin and set the parameter "OnDocFormSave" and the properties:
{
  "tv": [
    {
      "label": "Tags TV ID",
      "type": "input",
      "value": "5",
      "default": "",
      "desc": ""
    }
  ],
  "sep": [
    {
      "label": "Tag separator",
      "type": "input",
      "value": "||",
      "default": "",
      "desc": ""
    }
  ]
}

The plugin was installed 3 times (and renamed) for 3 sets of tags for 3 IDs
3. The snippet "urlencode" was created with the following:

<?php
return isset($input) ? urlencode($input) : '';
  1. Multiple documents that use the tags were then re-saved and the DB tables started to fill up
  2. The Doclister calls were created using the examples found in the forum page, but as noted, they don't work / don't show the tags

@AgelxNash if you have a moment could you help me out with this please ?

Using the following call:

[!DocLister? 
&debug=`1`
&id=`colourscheme` 
&controller=`site_content_tags` 
&tagsTV=`7` 
&tagsData=`static:[*colourscheme*]` 
&ownerTPL=`@CODE:<ul>[+dl.wrap+]</ul>` 
&tpl=`@CODE:<li>[+tag+]</li>`
!]

I get this debug information:

action time: 0.00077 · total time: 0.00221
SELECT 
  c.* 
FROM 
  `mysite-dev`.`evocms_site_content` as `c` 
  RIGHT JOIN `mysite-dev`.`evocms_site_content_tags` as `ct` on ct.doc_id = c.id 
  RIGHT JOIN `mysite-dev`.`evocms_tags` as `t` on t.id = ct.tag_id 
WHERE 
  t.`name` = 'Blue,Dark Grey,Green,Light Grey,Orange,Purple,Red,Turquoise' 
  AND c.parent IN ('586') 
  AND c.id NOT IN('586') 
  AND c.deleted = 0 
  AND c.published = 1 
GROUP BY 
  `c`.`id` 
ORDER BY 
  if(
    c.pub_date = 0, c.createdon, c.pub_date
  ) DESC

The names of the selected tags are all correct, as can be seen in the image below

03

But, they are not displayed / rendered in the HTML source, the only thing that gets rendered is the ownertpl <ul></ul>

If I use "get:[*colourscheme*]" or "get:colourscheme", the "RIGHT JOIN" isn't displayed in the Debug info

I am now out of my comfort zone and don't know further, I am hoping that someone can help out with this now

Much appreciated :)

UPDATE

I still can't get this to work using my DocLister calls from above, so I have resorted to using the "tagLinks" snippet to output the page tags

My problem is now:

The landing page where Doclister calls the related docs is showing all docs, not just the specific tag related docs

My page links look something like this:

<ul>
  <li><a href="/taglandingpage?tag=Blue">Blue</a></li>
  <li><a href="/taglandingpage?tag=Green">Green</a></li>
</ul>

So the result should be all of the docs for the tag "Blue" should be shown, but all docs are shown, it doesn't matter if they are tagged with "Blue" or not.

This is my DocLister call in my landing page:

<h1>Showing all pages tagged with: [+tag+]</h1>
[!DocLister? 
&idType=`parents` 
&parents=`11,12,13,14` 
&showParent=`0` 
&controller=`site_content_tags` 
&tvList=`myTags` 
&renderTV=`myTags` 
&tvPrefix=`` 
&tagsTV=`5` 
&tagsData=`get:myTags` 
&orderBy=`id DESC` 
&ownerTPL=`@CODE:<ul>[+dl.wrap+]</ul>` 
&tpl=`@CODE:<li><a href="[+url+]">[+menutitle+]</a></li>`
&display=`12` 
&addWhereList=`isfolder=0 AND hidemenu=1 AND published=1` 
&paginate=`offset` 
&PrevNextAlwaysShow=`1` 
&pageAdjacents=`2` 
&TplWrapPaginate=`@CODE:<nav><ul>[+wrap+]</ul></nav>` 
&TplFirstP=`` 
&TplFirstI=`` 
&TplLastP=`` 
&TplLastI=`` 
&TplPrevP=`@CODE:<li class="previous"><a href="[+link+]">Previous</a></li>` 
&TplPrevI=`@CODE:<li class="previous">Previous</li>` 
&TplNextP=`@CODE:<li class="next"><a href="[+link+]">Next</a></li>` 
&TplNextI=`@CODE:<li class="next">Next</li>` 
&TplPage=`@CODE:<li><a href="[+link+]">[+num+]</a></li>` 
&TplCurrentPage=`@CODE:<li class="active">[+num+]</li>` 
&TplDotsPage=`@CODE:<li>&hellip;</li>`
!]
<strong>Displaying [+from+] - [+to+] of [+count+] | Page [+current+] of [+totalPages+]</strong>
[+pages+]

@AgelxNash any ideas ? cheers :)