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

    I have a page containing an introduction, then a few different small sections of text accompanied by a thumbnail graphic and a long title/headline. Ideally, I would like to abstract everything out so the client only has to update the content in each of these small sections and not worry about them deleting the thumbnail graphic and or headline. I attached a screenshot. In the screenshot, I’m picturing the introduction being the document content of the page, then somehow including the other sections (each one abstracted out). If there was a way to do this while also maintaining the ability to update the longtitle/headline and thumbnail graphic, that would be great - I’m just looking for a place to start.

    Thank you!
    - Jess
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Template Variables will be your friend!

      This isn’t complete yet, but it should be enough for you to get a start with. http://www.sottwell.com/how-template-variables-work.html
        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
        • 20508
        • 157 Posts
        This was great for me to get started with, thank you. I’ve used TV’s for photos, but not content. To recap, I have intro text in the document content and a couple sections underneath that which has text an, <h4> (or longtitle) and a thumbnail image. I got the TV working so I can see an additional section below the document content. Now I’m wondering how to abstract out the <h4> as well as the image. I’m envisioning each TV like this to have a field for the thumbnail graphic and field for the <h4> and a field for the content (as shown), but I’m not sure how to pull that off.

        Thank you!
        - Jess
          • 20508
          • 157 Posts
          Also, my TV is returning text instead of HTML on the front end. I’m using "HTML" entities in the widget field so I’m not sure what’s happening. I attached a screenshot of TV screen.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            What does a view of the page source show? It looks like the HTML tags have been converted to html entities. Are you using rich text for the input editor?
              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
              • 20508
              • 157 Posts
              Yeah, I’m using RichText as the input type - I attached a copy of the source.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Well, there you see the problem. The rich-text input converted all the tags to entities. Either get rid of the rich-text input (make it a plain htmlarea) or don’t enter HTML tags into the rich-text editor; use its "code" or "html" window if you can’t use the rich-text editor’s formatting menu items.
                  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
                  • 20508
                  • 157 Posts
                  Hi Susan, thank you - I’ll change that. Any advice on how to abstract out a field for an image and an <h4> in the same template variable (see attached)? Thanks so much.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    I’d use the rich-text editor’s menu for that; use it just as you would for the main content area. Use the image button for the image, and use its format drop-down to format the caption with heading 4 tags.

                    You could enclose the TV tags in <div> container to add extra css styling opportunities, or add classnames to the TinyMCE configuration to allow the addition of classnames to the tags in the rich-text editor.
                      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
                      • 20508
                      • 157 Posts
                      What I ended up doing was make a TV for the image and for the content and just left the <h4> in the content. I included the TV’s in the template as so:

                      [*thumbnail-image-1*]
                      [*copy-1*]


                      [*thumbnail-image-2*]
                      [*copy-2*]


                      [*thumbnail-image-3*]
                      [*copy-3*]