We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39822
    • 6 Posts
    Hi folks. So I'm eager to learn with modx (despite it's horrible client editing platform - I wish it was something like concrete5 where clients can edit their website at face value in thir browser)..

    So, I have my own xhtml/css website. I want to convert it to modx CMS.

    So far I've imported the template and linked up all CSS and script..

    I made 5 documents... Home, Packages, Portfolio, FAQ and Contact..

    I've made chunks out of the static template content (header, footer, sidebar, etc).. So that I can edit them and they'll all change together.

    Where I'm stuck with is all the dynamic information (package, portfolio, faq, contact, whatever).. I don't know where to put it! Do they go in TV's?

    How do I link TV's to documents?


    DO I have to make 5 templates? Each with different links to chunks that contain the content HTML? (for instance I have a 'PackagesChunk' that has unique HTML suited to Packages page only...



    What I;m basically asking is.. How do I add unique content to my seperate documents under the one template?
      • 32316
      • 387 Posts
      Do they go in TV's?
      they could - or part of them could
      How do I link TV's to documents?
      You put a TV tag into your template
      [[*myTVname]]
      read this: http://rtfm.modx.com/display/revolution20/Template+Variables
      DO I have to make 5 templates?
      No
      Each with different links to chunks that contain the content HTML?
      Use chunks for html that will be used in multiple places - so that it can be edited in one place. The content html can go into the resource content field, no chunk needed, no multiple templates needed (unless you want them)


      If you have not checked out the rtfm pages yet they may be useful http://rtfm.modx.com/display/revolution20/Making+Sites+with+MODx


      You don't mention navigation - if you have not done so yet you check out wayfinder for this http://rtfm.modx.com/display/ADDON/Wayfinder
        • 3749
        • 24,544 Posts
        You generally want to minimize the number of templates. One way to have page-specific content is to put the content in various chunks and put the name of the appropriate chunk for the current page in a TV, like this:

        @CHUNK someChunk


        Then, you can display that chunk with something like this in the template:

        [[*TvName]]


        The tag is replaced by the content of the chunk named in the TV.

        If you set the default value of the TV to @INHERIT, its value for any page will be inherited from the nearest ancestor with the value set.

        If you need truly dynamic content, you can use a snippet that generates the content (often using $modx->getChunk() to pull the content from the appropriate chunk). The snippet tag will be replaced by the return value of the snippet.

        A more sophisticated version of that is to use Tpl chunks with placeholder tags in them. For a really simple-minded example, say you want to display the current time. You could create a Tpl chunk called ShowTime with this content:

        <p>The current time is: [[+current_time]]</p>


        Where you wanted to display that, you'd put a snippet tag:

        [[!CurrentTime]]


        Then create a snippet called CurrentTime with this code:

        <?php
        /* CurrentTime snippet */
        
        $time = $time = strftime("%a %d %b %H:%M");
        $modx->setPlaceholder('current_time', $time);
        return $modx->getChunk('ShowTime');


        Rather than using setPlaceholder(), you can send the placeholders in an array as a second argument to getChunk(). In that case, the snippet would look like this:


        <?php
        /* CurrentTime snippet */
        
        $time = strftime("%a %d %b %H:%M");
        $fields = array(
            'current_time' => $time
        );
        return $modx->getChunk('ShowTime', $fields);



        Welcome to MODX. smiley



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 32316
          • 387 Posts
          you might also want to look at this thread https://forums.modx.com/thread/?thread=73903&page=1
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            The most common "newbie" mistake when starting out with MODx is to overthink it. Templates and other elements are extremely simple, which most newcomers to MODx are not used to.

            Take the source of any HTML page that you like. Copy that HTML into a template. Assign a resource to use that template. Now when you view that page in your browser, you will see exactly the same page that you copied.

            The next step is to determine what is the main content of the page. It should not contain structure (HTML code) other than p or img or a tags; it should be just viewable content. Put that content into the main "content" field of the resource, and replace it in the template with the [ [*content] ] tag.

            Now, you can assign the same template to any resource, and have the different main content for each page inserted into the template for viewing.

            Continue this process with the rest of the bits of content you want to have changed for each page.

            The template contains the HTML structure, while the various MODx tags insert the bits of dynamic content that are relevant for each page.

            Template Variables are at their simplest just custom fields for resources so you can have more than the basic page title, long title, description, etc. fields on a given page.

            Chunks are for sections of HTML or content that can be used anywhere in a template or content. The real difference between chunks and TVs is that chunks are global, while TVs can be modified for each page. I often make the blocks of sidebar content chunks, then use a checkbox TV to offer a selection of which of these blocks of content are desired for the sidebar of each page.

            Snippets are for PHP code. If the snippet's code returns any output, it will be inserted into the page wherever the snippet's tag is located.
              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
              • 39822
              • 6 Posts
              Say I have a simple HTML document inserted as a MODx template...

              something like this,
              <html>
              <head>Hi</head>
              <body>
              <div id="nav>link1 link2 link3 link4</div>
              <div id="unique_page_content> Welcome to home </div>
              <div id="footer">End</div>
              </body>
              </html>


              The nav div and the footer div are made into chunks. They are not unique in each page.

              But the unique_page_content changes over each page. Thus I create a document called 'Home' and a document called 'About'. Both have unique text content.

              How do I call each document seperately? How does the 'About' document know to show when on the about page, and not home page? [ed. note: revealyourself last edited this post 14 years, 5 months ago.]
                • 3749
                • 24,544 Posts
                You need to put code tags around your code so we can see it.

                That said, I think that answer is as Susan suggested. Put the unique page content in the Resource Content field of the document (when you edit it by clicking on it in the resource tree) and put this tag in the template where you want to show it:

                [[*content]]



                See the site in my sig for information about creating templates and documents. I'm assuming that you're using MODX Revolution. Let us know if that's not the case.

                I sense that you might be confused about site organization and navigation. To get started, the site is organized by the structure of the Resource tree shown on the left side of the Manager. For your top-level documents, right-click on the 'web' folder in the tree and select 'Create - Create a Document here'. To create a child document in the tree, just right-click on the desired parent and do the same.

                Once you have a few documents, install the Wayfinder snippet and put this tag in the template where you want the menu to appear:

                [[Wayfinder? &startId=`0`]]


                By default, Wayfinder shows the menu as nested unordered lists, but you can style them any way you want.




                ------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using.
                MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 5 months ago.]
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 39822
                  • 6 Posts
                  Thanks BobRay, I sort of understand now..

                  [[*content]] 
                  is relative to the Content text field in each document.

                  Each document can have a custom content area which will be called by the template through the same action;
                   [[*content]].


                  I guess, what I further don't understand is,

                  My unique content is full of div's and styled lists.. How do I retain the formatting if I'm removing all HTML (besides p, a, etc).


                  edit: MODx Rev is what I use [ed. note: revealyourself last edited this post 14 years, 5 months ago.]
                    • 3749
                    • 24,544 Posts
                    There's no requirement to remove all that other HTML. What Susan was suggesting was that you want to move generic HTML (e.g. nav, sidebar, header, or footer divs) to the template.

                    Any HTML that's necessary for formatting the page-specific content is fine in the content field.


                    ------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using.
                    MODX info for everyone: http://bobsguides.com/modx.html
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 39822
                      • 6 Posts
                      Oh, I see.

                      Excellent. Thanks Bob.

                      One last (hopefully) things...

                      I've put
                      [[*content]]
                      into my template, as required.

                      In my home document, in the content area, I type something, say, 'Hello'. Theoretically it should appear in the region where I tagged it in the template right?


                      It doesn't :S

                      I must be missing something obvious =[