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

    What do I need to write to echo (show) one of the CMS pages at the frontend of my website?

    Im not a PHP master but is it something about <? include(test.php ?>
      • 21191
      • 236 Posts
      I’m not sure exactly what you want... but if you wanted to run that sort of php code you could create a snippet with said code.. and name it "echopage" for instance. then in your MODx document insert [[echopage]] to call the snippet and PHP code.

      However if I wonder that’s not really what you’re asking, and you just want to display a page. if that’s the case, it’s all driven from index.php with an id variable. However most installs use the friendly URL option these days.

      A problem well stated is a problem 1/2 solved
        ~Shawn Himmelberger
        Check out my MODx Development and MODx Design Company - Himmelberger Design
        • 21088
        • 85 Posts
        I just want to get the content from fx. ID 22 and insert the content into page with ID fx. e.g. 1

        Was it better explained?
          • 21191
          • 236 Posts
          Ahh... you want to include content from one MODx document in another MODx Document.

          http://modxcms.com/extras/package/115 Here is a snippet called DynContent we use it often to allow clients to easily edit include areas.
            ~Shawn Himmelberger
            Check out my MODx Development and MODx Design Company - Himmelberger Design
            • 21088
            • 85 Posts
            Yeah thats exactly what im looking for.

            How do I need to write the ! DynContent?docid=`9` ! on my CMS pages?

            I created a snipet with this inserted code and called it: DynContent

            <?php
            $docid = isset($docid) ? $docid : "";
            if(empty($docid)) return "";
            $doc = $modx->getDocumentObject(’id’,$docid);
            $output = str_replace(array("[!","!]"),array(""),$doc[’content’]); ;
            return $modx->parseDocumentSource($output);
            ?>

            And then i entered this on one of my CMS Pages: [[DynContent?docid=`83`]]

            But it is not showing anything on the frontend of my website.

            Has I done anything wrong?
              • 21191
              • 236 Posts
              [[DynContent?var=`value`&var2=`value2`]]

              Like that.
                ~Shawn Himmelberger
                Check out my MODx Development and MODx Design Company - Himmelberger Design
                • 21088
                • 85 Posts
                Like this: [[DynContent?var=`83`&var2=`83`]]

                ?

                Sorry im really new to php and modxcms sad
                  • 21191
                  • 236 Posts
                  Sorry that was just an example of basic snippet syntax.. you had it right a few posts above.

                  Is the snippet installed? and the snippet name is case sensitive
                    ~Shawn Himmelberger
                    Check out my MODx Development and MODx Design Company - Himmelberger Design
                    • 21088
                    • 85 Posts
                    I just used this instead: [[DynContent?docid=`9`]]

                    And it works. smiley

                    Thanks for the tip.
                      • 26931
                      • 2,314 Posts
                      I just want to get the content from fx. ID 22 and insert the content into page with ID fx. e.g. 1

                      or with a TV and @DOCUMENT binding
                      http://www.sottwell.com/tv-bindings.html