We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37165
    • 89 Posts
    I using Modx 2.1.3-pl and have created traditional website and a blog using this tutorial: http://rtfm.modx.com/display/revolution20/Creating+a+Blog+in+MODx+Revolution

    I have used taglister to create tags to apply to my blog posts and my links are working great.Everything is functional I am just having one problem, getting the proper titles to show up when the user click on tags.

    For example:
    When a user clicks on a tag they are brought to a resource that dynamically populates itself with all posts that have tags. For example if I click on a tag called "learn" I am brought to a page that shows all blog posts tagged with "learn." I need it to say the word "learn" at the top of this page so the user knows where they are and what they clicked on. I can't put it in as a page title or description because the same resource is used as the landing page for all tag queries. This is a pretty standard thing on wordpress and am stumped that I can not find the answer on modx. To give you more information about my site:

    This is what the url looks like after I click on a tag called "learn":

    /tag-and-archive-page/?tag=learn&key=tags


    this is the taglister call that requests the tag-and-archive-page as the target:

    [[!tolinks? &items=`[[*tags]]` &key=`tag` &target=`81`]]



    This is the template for the target:

    [[$head]]
    
    <body id="subLevel">
    [[*backgroundImage]]
    	<div id="pageWrapper">
    		[[$newMenu]]
    	<div id="contentWrapper">
    	<div id="mainSection" style="background-image:url('[[*orangeObject]]');">
    	  <a href="[[$siteName]][[UltimateParent]]"><h1>[[getResourceField? &id=`[[UltimateParent]]` &field=`pagetitle` ]]</h1></a>
    	<div id="leftNavigation">[[$blogMainMenu]]
    
    
    
    
            </div>
    	<div id="rightSideBlog">
    	  <h2>[[!getResourcesTag? $tagKey=`tag` &tagRequestParam=`tag`]]
    
    </h2>
    
                    <div id="mainContent">
                        [[*content]]
            </div>
    	</div>
    	</div>
    	  [[$r.footer]]
    	</div>
    	</div>
    
    	<script type="text/javascript">
            var DISModifyPost = $(function() {
                DIS.config.attachments_max_per_post = 5;
                DIS.DISModifyPost.init({
                    attachments: 1
                });
            });</script>
    </body>
    </html>
    


    and this is added into the content area of the target resource (81, tag-and-archive-page)
    [[!getResourcesTag? &parents=`71,72,73` $tagKey=`tag` &tagRequestParam=`tag`]]
    
    [[!getResourcesTag? &elementClass=`modSnippet` &element=`getResources` &tpl=`blogPost` &parents=`71,72,73` &limit=`36` &includeContent=`0` &includeTVs=`32` &processTVs=`32` &tvPrefix=`` &showHidden=`0` &hideContainers=`1` &cache=`0` &pageVarKey=`page` ]]
    
     
    
    [[!+page.nav:notempty=`
    
    [[!+page.nav]]
    `]]
    
    


    I've posted this several other times with no response and have spent a good deal of time researching this. Any help is greatly appreciated

    This question has been answered by charless. See the first response.

    • discuss.answer
      • 34084 ☆ A M B ☆
      • 756 Posts
      You could create a very simple snippet that would simply output the tag value when the key/value pair for tags is present in the query string.

      Vary basic snippet (ex snippet name: dyntagtitle):
      //-- Get all request string key/value pairs
      $s = $_REQUEST;
      
      
      
      if($s['key'] == 'tags'){
        return $s['tag'];
      } else {
       return false;
      }
      


      Then on the page template simply put the snippet call where you want it to be displayed:

      [[!dyntagtitle]]


      cheers
        Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
        Visit CharlesMx.com for latest news and status updates.
        • 37165
        • 89 Posts
        Charles, I can't thank you enough for this answer. This works perfectly! I'm going to copy and paste it to some other posts I put up because I know some other folks were looking for it too!


        THANK YOU!!!
          • 34084 ☆ A M B ☆
          • 756 Posts
          no problem, glad to help out
            Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
            Visit CharlesMx.com for latest news and status updates.
            • 39501
            • 163 Posts
            Just to let you know that the dyntagtitle snippet no longer works in the latest version of Revolution. Damit!
              • 18373 ☆ A M B ☆
              • 3,141 Posts
              There's nothing in there that even remotely uses the Revo API that *could* break after an update..?

              That said, I tend to use a slightly different approach which prevents E_NOTICE errors if your server is configured to show them:

              $param = $modx->getOption('param', $scriptProperties);
              if (!empty($param)) {
                if (isset($_REQUEST[$param])) {
                   return $_REQUEST[$param];
                }
              }
              return;

              use as:
              [[!nameOfSnippet? &param=`tag`]]


              Can't hurt to throw in some (real simple) sanitation either as we're dealing with user generated content:
              [[!nameOfSnippet:htmlentities? &param=`tag`]]
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 39501
                • 163 Posts
                Thanks for the post Mark. Will try and test and report back. After hours of searching through the forums i've started to spot a few other solutions, such as:

                https://forums.modx.com/thread/72278/taglister-how-to-display-the-selected-tag#dis-post-402264

                Does not look quite as graceful as your solution but it did the trick!
                  • 18373 ☆ A M B ☆
                  • 3,141 Posts
                  In the end all those solutions do the same. Mine may be overcomplicated, lol. And the first line is a bit obsolete, as any properties passed will already be set to a normal variable, so line 2 could just be isset($param) && !empty($param) for the same effect.
                    Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                    Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.