We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37449
    • 57 Posts
    Scenario:

    I have a container for my blog posts, which lists all my posts in descending date order. There is a side bar which has an Archivist and a tagLister call in, so I get a list of Archives by date, and a list of posts by Category.
    I then have two landing pages - one for the Archives and one for the Categories. The idea being that when you click on March 2011, it will take you to the Archives page and list the posts for that month/year.

    This works fine, and after a bit of hunting and digging, I found out how to get the Category as well, using getResourceField. See - http://modxcms.com/forums/index.php/topic,66687.0.html

    So, onto categories. In the Archives call, there are placeholders for the month and year, so updating longtitle was easy to do. In getResourceTags, however, I needed to find a way to get at the tv for the category selected from the side-bar.

    The same call for getResourceField (as used in the post above) works fine for the individual listed item, but I could not see a way to get to the tag that had been selected.

    I explained my problem to a friend who does a lot of PHP, and showed him the documentation for all the different snippets, and he picked out the solution straight away!

    This is the call on the Blog Category resource:
    <h3>[[*longtitle]] - [[!get-category]]</h3>
    [[$list-blog-category-post]]
    


    This is the list-category-blog-post chunk:
    <div class="blogPost">
    [[!getResourcesTag? &parents=`7` &tpl=`list-blog-category-post-tpl` &tagKey=`tvBlogTags` &tagRequestParam=`tag`]]
    </div>
    


    This is the list-blog-category-post-tpl (note the getResourceField call):
    <h4 class="blogPageTitle">[[+pagetitle]] ([[+longtitle]])</h4>
    <p class="blogSummaryText">[[+introtext]]<a href="[[~[[+id]]]]">  >>></a></p>
    <div class="blogDocumentInfo">Published on [[+publishedon:strtotime:date=`%b %d %Y`]] under 
    [[getResourceField? &id=`[[+id]]` &field=`tvBlogTags` &isTV=`1` &processTV=`1`]]</div>
    


    And finally, the snippet get-category:
    <?php
    echo $_GET['tag'];
    ?>
    


    I hadn’t understood the documentation enough to realise that I needed to extract a parameter passed by the getResourcesTag call, but this now works a treat!

    Hopefully someone else will find this useful..... If the explanation is not clear enough, shout and I will do a verbose version!

    Cheers
    Daz
      formerly sumodaz on here!