We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I want to use ContentBlocks for the MODX Cookbook. I have it installed, but after several weeks of poking at it from time to time, and reading and re-reading the documentation, I'm still having trouble figuring out how to set it up.

    The Cookbook recipe pages are all the same. There are four basic sections, with the addition of image blocks and code blocks. Sometimes one of the blocks, the "solution" block, will get duplicated if the forum post has more than one post flagged as an answer.

    So what I thought was to have four "blocks" with the structure of each block

    • Introduction - mostly just a paragraph
    • Question - link, username, question, within a specific HTML <section> element
    • Solution - link, username, solution, again a specific HTML <section> element
    • Discussion - just a heading and paragraphs
    and of course use image, code, and other provided fields as appropriate.

    My problem is that I don't know what to use to make these four blocks. Templates? Layouts? Should it all be in one template or layout? Should it be four templates in a layout?
      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
    • Ok. A Template contains Layouts. A Layout contains Fields. So I created four Layouts. I created a Template, inserted the Layouts into the template, and added the basic fields I wanted in each layout - i.e. just a richtext field for the Introduction layout, header link, and richtext fields for the Solutions layout, etc.

      I notice that the Template Builder doesn't load the Rich Text editor for a Rich Text field. Not that it's necessary, but it's good to know so that you don't think it's not working.

      Now to figure out how to make my Template be the default for all Recipe pages. [ed. note: sottwell last edited this post 9 years, 2 months ago.]
        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
      • Found out how to set a default template. Obviously enough, in the Default tab. duh.
          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
        • My problem is that I don't know what to use to make these four blocks. Templates? Layouts? Should it all be in one template or layout? Should it be four templates in a layout?

          For the most part, you would probably just have the different fields (heading, paragraph, quote etc), and place them in layouts matching how to show them in the front end.

          With certain use cases you could get real fancy and use special fields (likely with some field settings or repeater fields) to create really awesome editing fields.

          The case study here is a really good example of how ContentBlocks can be used from a user perspective, maybe that can help to get the idea: https://www.modmore.com/extras/contentblocks/case-studies/#jump_gi_joe_website_rebuild
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
          • Yeah, I could use a special field for the part of the question and answer blocks that have the link to the forum post being referred to. But so far I'm well-pleased with the template and layouts.
              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
            • That is an excellent tutorial, and I don't even like video tutorials!
                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