We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34108
    • 66 Posts
    Hi smiley I'm trying to get my Articles container template to display the tags associated with an article but I can't seem to get it to work.

    For example - if the user clicks on the "industry news" tag, they're taken to a new page showing all posts with that tag, but the page title doesn't change. What I'd like to be able to do is for the page title to change to that tag, so they don't just get "Blog" they get "Industry News".

    Is this even possible with the current version of Articles?

    Many thanks
    Harmony
    • I would use a snippet to get that value and put the snippet tag for the title in the main Articles template. You'll probably need to have a default value for when it's not loading specific tags.
        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
        • 37693
        • 47 Posts
        Yep, have a look at this thread: http://forums.modx.com/thread/?thread=73323&page=2

        This is the 'blogTitle' snippet we created:
        <?php
        $pagetitle = $modx->resource->get('pagetitle');
        $get = $modx->sanitize($_GET);
        if (ISSET($get['tag'])){
            $tag=$get['tag'];
            return 'Posts tagged with'.$tag;
        }
        if (ISSET($get['arc_year'])){
            return 'Articles posted during '.date( 'F', mktime(0, 0, 0, $get['arc_month'])).' '.$get['arc_year'];
        }
        if(ISSET($pagetitle)) {
            return $pagetitle;
        }


        Steps:

        1. Create a snippet called blogTitle
        2. Paste the code above into it and save
        3. Add [[blogTitle]] to your Articles container template where the title appears

        There are other variations in that thread – I hope that helps!

        Cheers,
        Shaun
        • I get + signs where there should be spaces in my tags using the code above. Anyway to strip those out? I understand that the URL has to put the + signs in between spaces but need those replaced by or a plain space. [ed. note: rx2 last edited this post 10 years, 1 month ago.]