We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18946
    • 2 Posts
    Can I show tags under the documents like is done in the resources page of this site? How? huh
      • 727
      • 502 Posts
      Create a template for each item. In the template use something like:

      <div class="tags">Tags: [*tags*]</div>
      


      Create a template variable called "tags" and add it to your template.

      Create a document based on the template and in the tags field enter your comma separated list.

      Use Ditto to show multiple items on one page.

      Now you just need to work out a way of parsing the tags for your needs. Might be some snippets already created for this.

      If you want more control over the tags, then you can use a snippet instead of [*tags*] to parse the comma seperate liste into links.

      Andy
        • 7455
        • 2,204 Posts
        if the snippetname does not exist then it will show the tag as text without parsing it (it does in the beta release) if this works for all the tags I do not think so.

        in the repository they made a special plugin I think it is that handels tags like [snippet]snippetname[/snippet] and translate them after the parser to [[snippetname]] I could be totaly of but I think it was somthing like this.
          follow me on twitter: @dimmy01
          • 14557
          • 48 Posts
          i have a TV called category, in which I type in a comma separated list of tags for each page. hen I have a snippet to display links for them at the bottom of the page (this snippet has a hard coded link to my site but I’m sure you can fix that!)

          $id = (!isset($id)) ? $modx->documentObject['id'] : "$id";
          $tv = (!isset($tv)) ? "category" : "$tv";
          $leadtext = (!isset($leadtext)) ? "See also: " : "$leadtext";
          $tvval = $modx->getTemplateVar($tv, "", $id);
          $result = "";
          
          if (!empty($tvval['value'])) {
            $categories = explode(",",$tvval['value']);
            foreach ($categories as $category) {
              if (empty($result)) {$result = $leadtext;}
              else {$result .= ", ";}
              // Ensure value is HTML safe
              $keyword = htmlspecialchars($category, ENT_QUOTES);
              // and a valid technorati tag
              $tag = str_replace(" ", "%20", $keyword);
              $result .= '<a href="http://www.specialfamilies.org/tag_information.html?tags='.$tag.'" rel="tag">'.$category.'</a>';
            }
          }
          return $result;


          The tag_information.html page just uses Ditto to display a list of the pages that have the tag in the query string. E.g.

          [!Ditto? &startID=`94` &tagData=`tvcategory` &tagDelimiter=`,` &summarize=`100` &truncSplit=`false` &sortby=`pagetitle` &sortdir=`asc`!]


          94 is the ID of my folder which contains the tagged articles.

          I hope that helps,

          John
            • 3011
            • 6 Posts
            Hello. I’m trying to set up tagging. I tried your setup exactly, but have been unable to get it to work.

            The only change I made was in defining the site URL. My site doesn’t use friendly URLS sad so the line in your snipped is changed to:

            $result .= ’<a href="http://www.myurl.com/index.php?id=17?tags=’.$tag.’" rel="tag">’.$category.’</a>’;

            Where id=17 is a page with:
            [!Ditto? &startID=`5` &tagData=`tvcategory` &tagDelimiter=`,` &summarize=`100` &truncSplit=`false` &sortby=`pagetitle` &sortdir=`asc` !]

            When I call the snippet, the tags and their associated links are output perfectly. I.e.:
            <a href="http://www.myurl.com/index.php?id=17?tags=test" rel="tag">test</a>, <a href="http://www.myurl.com/index.php?id=17?tags=blog" rel="tag">blog</a>

            However, clicking on the links produces a 404 error. The document with id=17 certainly exists, so I’m just wondering if the problem is the fact that there are 2 items in the query string, ’id’ and ’tags’.

            Any help would be greatly appreciated.
              • 31037
              • 358 Posts
              Quote from: beepbeep at Nov 26, 2006, 03:27 AM
              &sortdir=`asc`! !]
              Hi, I have no idea what you’re discussing, but you have an extra "!" in your call.
                • 3011
                • 6 Posts
                Whoops! You’re right, edited!

                I’m new to MODx and I’ve gotta admit that when I deleted that extra ’!’ I was hoping that would magically fix everything.

                No such luck grin
                  • 867
                  • 241 Posts
                  Hi !

                  Could someone explain that : "then you can use a snippet instead of [*tags*] to parse the comma seperate liste into links." ??!

                  What kind of snippet would transform them in a link with a ditto call of the tag in the <a ref >tag </a>

                  Thanks for any help.

                  Alchime
                  (fr)
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    $result .= ’<a href="http://www.myurl.com/index.php?id=17?tags=’.$tag.’" rel="tag">’.$category.’</a>’;

                    You can’t have two ? in the URL like that. The first one (?id=17) needs to be a ?, but all subsequent key->value pairs need to have & (&tags=’.$tag.’). That’s why it will work with friendly URLs. Snippets that automatically add to the query string like that need to check for the status of friendly URLs, and if it’s on use ? and if it’s off use &.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 3011
                      • 6 Posts
                      *sigh* very good point Susan. It’s amazing how you overlook the simple things by assuming the problem is more intricate than it is.

                      Thank you so much, it works perfectly now.

                      For others who are trying to implement this method (and aren’t using friendly URLs) the line in the snippet just looks like this:

                      $result .= ’<a href="http://www.yoursite.com/index.php?id=17&tags=’.$tag.’" rel="tag">’.$category.’</a>’;