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

    I succeed in using NewsListing snippet with simple articles (1 document per article), but I’m wondering how to do with multi-document articles ?

    I want NewsListing shows all articles and when I click on "read more", I want to go to the first page of the article with a drop list of all the page of the article (Intro, body1, body2, ..., conclusion). On each page I want a sort of template of the content section with Author, date of creation of the article (not the document), the drop list of the page of the article, a navigation menu, and the comments add by reader. The comments should be displayed on all the page and concern the article and not a single document of the article.

    Is it possible by using NewsListing, UserComment and other snippets to do without editing each document of the article for placing the comments and the navigation stuff ? huh

    Thank to help me if you have already done that or if you now how to do smiley

    I hope my project is clear and excuse me if my English is not perfect (French newbie sucks grin)
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The "sort of template section" could probably be done with a TV. The @INHERIT binding would be useful here, I believe.
        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
        • 18397
        • 3,250 Posts
        You can do everything you say.

        Off the top of my head this is what you need to do:

        1. For all of your multipage articles create a wrapper folder and place each article within it.
        2. When calling the UserComments snippet on each page, do so with a docID equal to the containing folder.
        3. Use getDocument to have the folder display the first child’s document as its content.
        4. Use NewsListing with set to the parent folder of all your news (Don’t turn on multilevel).
        5. Test everything out and make sure it works.

        If you need more help let us know.
          • 22221
          • 283 Posts
          I’ve problem with the UserComment, I don’t know how to have the same comment on all the page of an article.

          I’ve tried to use in each page of the folder of the multipage article
          [!SMF_UserComments? &folder=`[*parent*]` &tagid=`[*parent*]` ... !]

          But when I post a comment, the snippet create "page1 - comments" document if i post from the firs page, "page2 - comments" document if i post from the second page, ....

          Is there any other option in the snippet to do what I’ve planned
            • 18397
            • 3,250 Posts
            As I said, use docID.
              • 22221
              • 283 Posts
              Sory, I watch the UserComment documentation on the website and this option wasn’t described. I look in the documentation in the code of the snippet anf I found it tongue.

              Now it works, thanks grin
                • 15159
                • 93 Posts
                A very succinct and clear how to mark. I thought this was a stumper when I first saw it. I am book marking this becuase I know I am going to need it when I publish my online book. (har har har.) <-- This be sarcasm. The day I publish a book will be the day my therapist says "Great, we cured your ADD."
                  • 18397
                  • 3,250 Posts
                  Thank you for the compliment and good luck with your online book.
                    • 22221
                    • 283 Posts
                    Thanks for your help Mark, It works partially and I think I’m very close to match with my original project. grin
                    1. For all of your multipage articles create a wrapper folder and place each article within it.

                    2. When calling the UserComments snippet on each page, do so with a docID equal to the containing folder.
                    3. Use getDocument to have the folder display the first child’s document as its content.
                    4. Use NewsListing with set to the parent folder of all your news (Don’t turn on multilevel).
                    5. Test everything out and make sure it works.

                    I’ve some problem’s with the third step.
                    I use the GetDoc snippet to have the content of the first page displayed in the folder BUT currently I’ve snippets and TV in the document (PrevNext and User Comment). This stuff don’t work correctly when they are call form the folder.
                    I know that one solution could be to put the snippet call and TV in the template and make difference between the folder and page template. But I wonder if there is more convenient solution ? Is there any way to redirect automatically to a document ? Or to get the content of another page but after the parsing not before ?

                    Thanks

                      • 18397
                      • 3,250 Posts
                      Redirecting is a piece of cake. Try this:

                      Quote from: Djamoer at Feb 23, 2006, 08:46 AM

                      Here is another quick little snippet that might serve your need as well.

                      // Create a new snippet and name it RedirectPage
                      // Call it using [!RedirectPage? &docid=`5`!]
                      // docid will be the page id number for your redirection
                      if(isset($docid) && $docid != $modx->documentIdentifier)
                        $modx->sendRedirect($modx->makeUrl($docid));
                      



                      To do it more elegantly (without the reload) you could simply alter you NewsListing template so that instead of linking to
                      [~[+id+]~]
                      you link to a snippet with the following content:

                      if(isset($docid) && $docid != $modx->documentIdentifier)
                      $id=$modx->documentIdentifier;
                      $children=$modx->getActiveChildren($id,'menuindex','ASC');
                      if (!$children===false)
                      {
                      $firstChild = $children[0];
                      $firstChildUrl = $modx->makeUrl($firstChild['id']);
                      }
                      else
                      {
                      $firstChildUrl = $modx->makeUrl($modx->config['site_start']);
                      }
                      return $firstChildUrl;
                      


                      Replacing,
                      [~[+id+]~] 
                      with
                      [!SnippetName?docid=`[+id+]`!]