We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21054
    • 78 Posts
    Hi,

    I’ve been playing around with trying to place the "Tags" and pagination on the actual blog article (i.e. after clicking on the link made by the Ditto call). I’ve been receiving some PHP errors and I think I’m getting it all wrong.

    Is there a tutorial on how to access these variables on the blog page itself?

    Many thanks and Happy Holidays!
      • 16278
      • 928 Posts
      Once you click on the item’s link, you’re working outside of Ditto on a normal document, so you don’t have access to Ditto-generated placeholders etc. If you can be more precise about what you want to do by way of pagination (e.g. remember what page of the list you came from for a return link, or maybe split a long article?) I expect someone will have an answer.

      As for tags, here’s what I have in a full-post template. Note that I use the delimited list widget on my tag TV, using a comma as delimiter:
      <?php
      //PostTags: create links from post's tags to tag-roundup page
      // Updated 3 Sep 09
      //
      // parameters:
      // &tagShow: ID of tag summary page (MANDATORY)
      // - must be a page with a Ditto call with tagging extender
      // &tags: TV containing list of tags
      // &delimiter: tag separator; default to comma
      // &postDate: unixtime date; default to createdon
      // &dateFormat: strftime date format for output; default to %c
      
      if (!isset($tagShow)) return "tagShow parameter must be set";
      
      $delimiter  = (isset($delimiter)) ?  $delimiter  : ',';
      $dateFormat = (isset($dateFormat)) ? $dateFormat : '%c';
      
      $output  = '<div id="postDate"><h5>';
      
      $postDate = (isset($postDate)) ? $postDate : $modx->documentObject['createdon'];
      
      $output .= strftime($dateFormat,$postDate);
      
      if (!empty($tags)) {
          $tagList  = explode($delimiter, $tags);
          $tagLinks = ' <span id="tagLinks">';
      
          foreach ($tagList as $tag) {
            $tagLinks .= '<a href="[~' . $tagShow . '~]?tags=' . trim($tag).'">' . $tag . '</a>, ';
          }
      // remove trailing comma and space
          $tagLinks  = substr($tagLinks,0,-2) . '</span>';
      }
      
      $output .= $tagLinks . '</h5></div>' . "\n";
      
      return $output;
      ?>
      If you don’t have a special page to display sets of items filtered by tag, your &tagShow parameter will be the main Ditto listing page.

      Hope this gives you some ideas, at least.
      smiley KP
        • 21054
        • 78 Posts
        Hey kp52.

        Actually, splitting a long article is a great idea! If someone out there knows how that can be done...

        Thanks for that snippet code. It make total sense to me... except that I can’t get it to work (I’m still to get my head totally around snippet programming)

        I’m calling it like this in the blog/article template:

        [[PostTags &tagShow=`86` &tags=`documentTags` ]]


        Document 86 is a page that displays blog entries with a particular tag:
        [!Ditto? &parents=`90,92` &display=`6` &removeChunk=`Comments` &tpl=`BlogTemplate` &paginate=`1`&extenders=`summary,dateFilter` &paginateAlwaysShowLinks=`1` &tagData=`documentTags` !]


        There is no output. Seems like it things $tags is NULL (ie it seems to resolve !empty($tags) to TRUE)

        Sorry to be such a nag/amateur!

        Happy Silly Season by the way smiley
          • 16278
          • 928 Posts
          You’ll always need a question mark after the snippet name; the first ampersand is optional. And probably make the call uncached
          [!PostTags? &tagShow=`86` &tags=`documentTags` !]
          or
          [!PostTags?tagShow=`86` &tags=`documentTags` !]

          (I haven’t checked the Ditto code - still have a few presents to wrap!)
          Merry Crimble
          rolleyes KP
            • 21054
            • 78 Posts
            Merry Crimble smiley [... and on a sugar high right now]

            Okay now the output is this:

            Tue Dec 22 03:26:40 2009 documentTags

            Where "documentTags" is a link, which takes me to the Tags page... and of course, it says : "No documents found."

            The ditto call on the main blog article listing page is space delimited. Would that be making a difference?
              • 21522
              • 3 Posts
              Hey, in case you didn’t get this working, i figured out that you need to put
              &tags=`[*tvName*]`
              instead of
              &tags=`tvName`
              ...

              works fine for me that way