We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28275
    • 2 Posts
    hi MODX-folks,
    it’s something like an advanced newbie-question, but I can’t manage to find the right doc-page sad
    This is the resource-content of ’Archives’ from MODx Sample-Content:
    [[!getPage?
      &element=`getArchives`
      &elementClass=`modSnippet`
      &tpl=`blogPost`
      &hideContainers=`1`
      &showHidden=`1`
      &pageVarKey=`page`
      &parents=`2`
      &includeTVs=`1`
      &toPlaceholder=`archives`
      &limit=`10`
      &cache=`0`
    ]]
    
    <h3>[[+arc_month_name]] [[+arc_year]] Archives</h3>
    
    [[+archives]]
    
    [[!+page.nav:notempty=`
    <div class="paging">
    <ul class="pageList">
      [[!+page.nav]]
    </ul>
    </div>
    `]]
    

    My question is about [tt]<h3>[[+arc_month_name]] [[+arc_year]] Archives</h3>[/tt] and [tt][[+archives]][/tt].
    I know, [tt][[+NAME]][/tt] is a placeholder-tag.
    Snippets and Chunks may have property-sets (another name for placeholders?) attached to them. But not with this content - no properties. sad
    Chunks or Snippets may get params with their call. To access these params (just another name for placeholders and properties ?) I have to use the placeholder-tag, too: [tt][[+PARAM]][/tt].
    so far, I understand the semantics.

    but this is a resource, no snippet or chunk. sad
    WHERE do these placeholders get their values ?

    In case of the above content-sample, does the Snippet [tt]getPage[/tt] export/create these placeholders ?
    (I assume yes)

    Where do I find the docs about placeholders - how to create and how to export ?
    [tt][[+modx.user.id]][/tt] is another example. Are there other global placeholders ? Where are the docs ?

    any help/hints appreciated!

    Marc
    • Placeholders are always set by a snippet (or plugin, using an API function or method in the case of Revo); they are put into a MODx array that is then used to replace the placeholder with the content in its array element. These can be used in a tpl, thus being applied to each resource being processed to generate the list (as in Wayfinder or getResources) or can be used in the page where the snippet is called, depending on their purpose.

      Snippet parameters are not at all related to placeholders. They are converted to variables for the snippet code to use. Older snippets would have long lists of variable definitions in the beginning of their code that the user would have to modify manually. Then it eventually became the practice to write snippets so that just about anything could be configured using parameters in the snippet tags.

      You can see what placeholders are available by making a snippet to dump the "$modx->placeholders" array (at least in Evo; I’m not real sure how Revo handles them). There are no "global" placeholders; they are all set and used by snippets. The snippet code can itself fetch the placeholder value and replace the tags in its chunk tpls, or MODx itself can process them as part of the parsing process. So what placeholders are available and how they can be used are all dependent on what snippets are used.



        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
        • 28275
        • 2 Posts
        hi,

        thx for your explanation. I’ve started with your idea of dumping the $modx in a snippet - and it helped me a lot to understand.
        there must be at least two global (not set from one of my snippet-calls) placeholders: [tt]modx.user.id/modx.user.username[/tt].
        (a search for [tt]modx.user.username[/tt] does not reveal any placeholder-article, but MODX Users and MODX Object and Filters)

        I’m just still missing the paragraph in ’Developing in MODx’ of http://rtfm.modx.com/display/revolution20 about how this all works:
        [process data with snippet] -> [set placeholder(s) in snippet-code] -> [refer to placeholder(s) in content (and/or chunks)]

        But anyway, after hours of reading and searching the modx-picture becomes more and more clear.
        I will continue with api-docs and check getPage/getResource/getArchive-code for how these snippets deal with it.

        Marc