We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40728
    • 29 Posts
    Hi,

    I'm having a hard time learning to understand modx, and in particular how the articles list on my homepage is built. I added the articles package, and am slowly modifying the templates, but I can't figure out where the markup is for the items displayed in the container (if that makes sense)

    Can anyone point me in the right direction? Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That comes from the "Content" field of the resource, whether it's an Articles resource or one from the Tree. Actually, they are no different. Articles resources are in the same database table as the others, and have all the same variables as all the others. They're just managed differently in the Manager.

      The lists are made using getResources and other listing snippets. These snippets use their own mini-templates to apply to each resource they process when generating the list for display. Another similar listing snippet that uses its own mini-tpls is Wayfinder.

      A good exercise is to follow the tutorial for using getResources to create an RSS field. http://rtfm.modx.com/display/ADDON/getResources.Building+a+RSS+feed
        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
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        This is a pretty good discussion on the basics of MODx. http://rtfm.modx.com/display/revolution20/Making+Sites+with+MODx

          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
          • 39932
          • 483 Posts
          If you didn't create the markup in the Content of the Container you created, then it is in the Template. On an initial install of Articles, the Template is "sample.ArticleContainer". From there, you may see Chunks and snippet calls. These are a little more difficult to find as they are in the File System (Media Source) rather than your Elements list.

          The path to the Articles Chunks and Snippets are in "core/components/articles/elements/"

          You may copy and adjust any of these to your Elements. If you rename them, you will have to change the calls in the Template. This is done in the Advanced Settings of each Container you create. This allows you to have each Container have different setups.

          Also, certainly make sure that you read the links that sottwell provided. They explain a lot of how MODX works.
            Website: Extended Dialog Development Blog: on Extended Dialog
            Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
            Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

            Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
            • 40728
            • 29 Posts
            fuzzicallogic, thanks, I'm getting a better grip on building my pages in modx. The question remains however, let me try to rephrase it.

            In sample.ArticleContainer there's a template variable [[*content]] (according to the modx docs this is a template variable, I don't see it listed in my TV's though).

            This is where a list of recent blogposts will show up.

            I somehow figured out how to modify the template of the blog posts that are listed here, but I can't figure out how [[*content]] is filled / configured, ie. how many blog items will show up there.

            Eventually I want to break it up in two lists, with the #1 most recent item on top, then inset something else, and then continue the list of recent posts.

            Am I being clear, or am I rambling on? smiley


              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Do you mean this?
              <div class="sidemenu">
                <h3>Latest Posts</h3>
                <ul>
                [[+latest_posts]]
                </ul>
              </div>
              

              That is a placeholder; it's used by the core/components/articles/articles.container.class.php on line 401. It inserts a pre-configured getResources snippet call at that location in the template.
                  public function getLatestPostsCall($placeholderPrefix = '') {
                      $settings = $this->getContainerSettings();
                      $output = '[[getResources?
                          &parents=`'.$this->get('id').'`
                          &hideContainers=`1`
                          &showHidden=`1`
                          &tpl=`'.$this->xpdo->getOption('latestPostsTpl',$settings,'sample.ArticlesLatestPostTpl').'`
                          &limit=`'.$this->xpdo->getOption('latestPostsLimit',$settings,5).'`
                          &offset=`'.$this->xpdo->getOption('latestPostsOffset',$settings,0).'`
                          &sortby=`publishedon`
                          &where=`{"class_key":"Article"}`
                      ]]';
                      $this->xpdo->setPlaceholder($placeholderPrefix.'latest_posts',$output);
                      return $output;
                  }
              


              You can actually replace the placeholder tags with your own getReources snippet call to customize the output.
                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
                • 40728
                • 29 Posts
                No that is "recent posts" in the sidebar.
                I mean the list of posts that appear on the blog's homepage.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Ah, the
                  [[+articles]] 
                  
                  [[+paging]]
                  

                  placeholders that are inserted into the main resource's content by default.

                  Same file, different functions. The main "articles" listing placeholder is replaces with a rather lengthy getPage snippet call:

                          $output = '[[!getPage?
                            &elementClass=`modSnippet`
                            &element=`getArchives`
                            &makeArchive=`0`
                            &cache=`1`
                            &parents=`'.$this->get('id').'`
                            &where=`'.$this->xpdo->toJSON($where).'`
                            &showHidden=`1`
                            &includeContent=`1`
                            &includeTVs=`'.$this->xpdo->getOption('archivesIncludeTVs',$settings,0).'`
                            &includeTVsList=`'.$this->xpdo->getOption('includeTVsList',$settings,'').'`
                            &processTVs=`'.$this->xpdo->getOption('archivesProcessTVs',$settings,0).'`
                            &processTVsList=`'.$this->xpdo->getOption('processTVsList',$settings,'').'`
                            &tagKey=`articlestags`
                            &tagSearchType=`contains`
                            &sortby=`'.$this->xpdo->getOption('sortBy',$settings,'publishedon').'`
                            &sortdir=`'.$this->xpdo->getOption('sortDir',$settings,'DESC').'`
                            &tpl=`'.$this->xpdo->getOption('tplArticleRow',$settings,'sample.ArticleRowTpl').'`
                  
                            &limit=`'.$this->xpdo->getOption('articlesPerPage',$settings,10).'`
                            &pageLimit=`'.$this->xpdo->getOption('pageLimit',$settings,5).'`
                            &pageVarKey=`'.$this->xpdo->getOption('pageVarKey',$settings,'page').'`
                            &pageNavVar=`'.$this->xpdo->getOption('pageNavVar',$settings,'page.nav').'`
                            &totalVar=`'.$this->xpdo->getOption('pageTotalVar',$settings,'total').'`
                            &offset=`'.$this->xpdo->getOption('pageOffset',$settings,0).'`
                  
                            &pageNavTpl=`'.$this->xpdo->getOption('pageNavTpl',$settings,'<li[[+classes]]><a[[+classes]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>').'`
                            &pageActiveTpl=`'.$this->xpdo->getOption('pageActiveTpl',$settings,'<li[[+activeClasses]]><a[[+activeClasses:default=` class="active"`]][[+title]] href="[[+href]]">[[+pageNo]]</a></li>').'`
                            &pageFirstTpl=`'.$this->xpdo->getOption('pageFirstTpl',$settings,'<li class="control"><a[[+classes]][[+title]] href="[[+href]]">First</a></li>').'`
                            &pageLastTpl=`'.$this->xpdo->getOption('pageLastTpl',$settings,'<li class="control"><a[[+classes]][[+title]] href="[[+href]]">Last</a></li>').'`
                            &pagePrevTpl=`'.$this->xpdo->getOption('pagePrevTpl',$settings,'<li class="control"><a[[+classes]][[+title]] href="[[+href]]"><<</a></li>').'`
                            &pageNextTpl=`'.$this->xpdo->getOption('pageNextTpl',$settings,'<li class="control"><a[[+classes]][[+title]] href="[[+href]]">>></a></li>').'`
                  
                            '.$this->xpdo->getOption('otherGetArchives',$settings,'').'
                          ]]';
                          $this->xpdo->setPlaceholder($placeholderPrefix.'articles',$output);
                  


                  Again, you can replace that placeholder with your own getResources, getPage, or any other suitable snippet call.
                    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
                    • 40728
                    • 29 Posts
                    Okay I get it now. Last thing, as per the doc here: http://rtfm.modx.com/display/revolution20/Snippets

                    I'm trying to modify the output with parameters like this:

                    [[+articles? &limit=`1`]]


                    but that doesn't do anything.

                    I see the in the configuration the items per page and # of pages in the pager, that I can change, but if I want to do something like


                    • article 1
                    • advertisement
                    • article 2
                    • article 3
                    • etc..

                    Should I even use this [[+articles]] tag for that at all?

                    Thanks so much for your help!
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      That's not a snippet, it's a placeholder used by the internally configured getPage snippet. You probably need to replace the placeholder with your own getPage snippet call.
                        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