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

    I am currently trying to create a 'sidebar' sort of element for a website. I have created a template variable and given it access to a resource. It works fine on that page, but now I want to copy the sidebar code over to other pages. However, when I do this nothing shows up.

    I am guessing it is something to do with giving the different templates access to the template variable, but then when I do that I have to manually set the template variable per resource. What can I do so that I only have to set the template variable on one resource, but it works for all of the pages I need it on?

    Sorry if that does not make sense, I can explain further if needs be.

    Andy

    This question has been answered by claytonk. See the first response.

      • 3749
      • 24,544 Posts
      If the value doesn't change from page to page, use a chunk rather than a TV (with a chunk tag in the Template). TVs are for page-specific information and are significantly slower to process.
        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
        • 51867
        • 19 Posts
        Hi Bob

        Thanks for the quick reply as always!

        How would I give the person updating the site (I am building this as a favour for a friend) access to this to update it if I did this as a chunk?

        Currently, I am using the sidebar to display a featured artists section. This is set up so that I have a resource list TV (that is currently set to have home page template access only, as this was the page I started building first) that displays a list of the artists they have uploaded to the site (it is a record label, and the artists are child resources of a container resource using collections). This works fine for the home page, but then displays nothing on the other pages where the sidebar is placed. I guess thats to do with template access, but if I give the TV template access to any other page I have to manually set it again.

        How would I go about setting it so that it is a site wide setting instead? So that they select which artist they want to feature from a drop down list and then it allows every page to access this where required? Can I do that with a TV, or is there some other way to set site wide information?

        Andy
        • discuss.answer
          • 5430
          • 247 Posts
          You might look at something like https://rtfm.modx.com/extras/revo/fastfield which would allow you to insert a tag in your template that would output the TV values from only the page on which they are set. This would allow your users to make the changes to the TV values on the homepage but those values would be displayed on all pages.

          Another option is to setup a custom dashboard element which could link them to the chunk edit interface so they could edit a chunk directly.

          Depending on the complexity of the content they need to edit and what utilities you need present in that inteface (media browser, etc.) you could even go so far as to have this be it's own resource and you could simply call in the content field from that resource into any location on your template you need using something like fastfield or, if you're using pdoTools, pdoField is also good.

          So many options...that's why we love MODX.
            • 51867
            • 19 Posts
            Hi Claytonk

            FastField worked perfectly. Thanks so much.

            I do indeed love ModX. It takes some serious getting used to over other CMS' but it so much more powerful out of the box. That said, I wish there was a bit of an overhaul on the documentation side of it. It can be a real mission to find what you are after sometimes, trawling through endless forum posts and the like.

            Anyway, thanks again!

            Andy
              • 3749
              • 24,544 Posts
              Yet another way to go is to create a System Setting (assuming that the value is not too large). To let the user set the value, you can use Mark Hamstra's ClientConfig, or you can create a front-end form with a fairly simple snippet to set the value, or you can create a Custom Manager Page (with or without MIGX), or you can create snippet-type Widget.

                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