We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37042
    • 384 Posts
    I notice there's a couple of great placeholders used in the Articles sample templates

    [[+latest_posts]]
    [[+latest_comments]]
    [[+tags]]
    [[+archives]]

    I dropped these into a template variable on some non Article resources across the site but they dont seem to output anything.

    I was hoping to have a mix of them on every pages footer.
    Should these work on non Article resources?
      ...
    • No, they only work in the Articles tpl. It would usually not be useful, as the placeholders are applied to each item in turn as the list of summaries is being generated, so how could you possibly control which one's value is being used elsewhere on the page?

      I have a situation where only one item is displayed at a time, with full pagination for several items at a time. I wanted the displayed item's summary (introtext) in my logo area. I ended up using a bit of javascript to set the innerHTML value of the element in the logo area to the innerHTML of the displayed item's summary element, while hiding the value in the content. Actually, I think I might be better off using a single hidden text input field in the Articles tpl and use its value instead. That way it would be hidden even if the visitor has javascript turned off.

      At the bottom of the template I have this code

      document.getElementById('intro').innerHTML = document.getElementById('summary').innerHTML;
      document.getElementById('summary').style.display = 'none';

      [ed. note: sottwell last edited this post 12 years, 4 months ago.]
        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
        • 37042
        • 384 Posts
        Hi Susan

        I think I understand. Thanks for answering.

        >>so how could you possibly control which one's value is being used elsewhere on the page?

        I guess I thought that any individual post *could* have overall blog information on the right hand side of the page such as

        - Latest Posts
        - Archive by month
        - Latest comments
        - Tags

        Why not? if you could somehow tell the placeholders to fetch this information from the overall blog.

        Still a bit confused about this. One of the great things about MODX for me is the ability to pull content from anywhere on the site and repurpose it across as many pages and places as I want.
        Maybe I got that wrong :-/

          ...
        • No, those are all from separate snippet calls. And each of their placeholders are only valid within their respective tpls during processing.
            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
            • 13373
            • 70 Posts
            You can just use the individual snippet calls, for example I just use the following getResources call in a chunk that gets displayed on all pages throughout the site:

            [[!getResources? 
              &parents=`9`
              &hideContainers=`1`
              &tpl=`latestPostsTpl`
              &limit=`1`
              &sortby=`menuindex`
              &showHidden=`1`
            ]]

            where 9 is the articles resource.

            Is that what you were looking for?

            Cheers,
            Jacob
            • Ok, I see what you mean. The Articles package runs the getPage and other listing snippets internally and puts their output into placeholders, so you can use those placeholders in your custom Articles templates. http://rtfm.modx.com/display/ADDON/Articles.Theming+Articles has a listing of the global placeholders that you can use in your own templates.

              However, these will only be available if these are ArticlesContainer or Articles objects. From what I can understand, the Articles page and its children are assigned a different class_key, and so are not generated as modDocument resources the way most pages are, but as Article type resources, while the main Articles page is an ArticlesContainer type resource. Exactly what kind of changes this makes in the generating of the pages I'm not yet sure of, but most certainly the Articles-specific placeholders won't be available on non-Articles pages. As Jaobkball illustrated, you would need to have your own getPage or getResources or whatever listing snippets you want to use, specifying the main Articles resource as the parent.
                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
                This is a shame that we can't tie into articles containers by id and use e.g.
                [[+archives id=`42` ]]
                or
                [[+tags id=`12` +]]
                I'd imagine lots of people want global sidebars, headers and footers that show archive or tag information whether you are within an articles container or not.

                Currently, to create these universal ares using
                [[!Archivist? &target=`9` &parents=`2`]]
                &
                [[!tagLister? &tv=`articlestags` &target=`2`]]


                This is no problem, but it does make some parts of the (mostly great) spangly new Articles admin area feel redundant.

                There's other useful functionality that's not available outside of the articles container such as
                [[+comments_enabled:is=`1`+]]


                Cheers,
                Shaun
                  • 28215
                  • 4,149 Posts
                  Articles (in the most recent versions) comes with an Articles snippet, that you can use like so:

                  [[Articles? &container=`IDOFCONTAINER`]]
                  


                  You can put that in any page, and that gets you all the placeholders that are normally in the Articles Container page, ie like:
                  [[+latest_posts]]
                  [[+archives]]
                  [[+tags]]
                  etc
                    shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                    • 37693
                    • 47 Posts
                    That is superb! Thank you very much. Loving 2.2!
                      • 38188
                      • 17 Posts
                      this is exactly what i was looking for. Thank You!