We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19872
    • 1,078 Posts
    Kind of working on the fly here and thought I ask for tips in handling Template Variables. I have a project resource that will contain a gob of template variables. When completed, it would be great to have them all in a "logical" order so that they are easier for the user to fill out. Is the "Sort Order" the only way to control their order of appearance in the resource manager?

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      On the TV tab of the Create/Edit Resource panel, TVs will be organized by the category they are in. Within the category, they will be sorted by their rank field.

      In the Elements Tree, they'll also be in the categories, but in alphabetical order by the name of the TV.
        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
        • 19872
        • 1,078 Posts
        Thanks Bob:

        When you say "rank field"... is that the sort order? So then the way for me to order them in the Create/Edit panel, I would probably want to get them all created, and then just change the sort order, which works fine until I need to create a new one in spot 3 and then have to adjust the numbers of the remaining 15 or so. Ha! Thorough planning is a good idea I guess.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Maybe a custom resource type would be a better solution? BobRay's ClassExtender would do the job. http://bobsguides.com/classextender-class.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
            • 19872
            • 1,078 Posts
            Hi Susan: Thanks for the tip.
            I gave that a quick review. Looks promising, but I fear could be a detour for me at this point.

            Pressed for time — I need to just get items input and the page structure created. Once my template is constructed I have about 20 pages I need to create for the site.
            in the past, I entered a numeral in the "sort order" field for each TV and that worked OK for ordering a TV in the create/edit panel. This seemed to help for example from having the TV for an image appearing somewhere at the top but then the selector TV for that image appearing at the bottom.

            But is sort order an OK method for controlling the order of the TV within the Create/Edit panel.

            Otherwise—I guess I could use the alphabet and name the TVs something like A-MainImage, B-MainImage_Selector, etc. etc.
              • 3749
              • 24,544 Posts
              What you're planning should work, but if you're going to use the TVs for any searching or sorting of resources, you really should extend modResource as Susan suggests. It's not as difficult as it sounds.
                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
                • 19872
                • 1,078 Posts
                Hmmmm? I am going to want to be sorting.

                It's a real estate site. Will have a dozen our so resources for each listing, but I DO want to have a landing page that pulls a photo, title, price, etc from each resource and arranges them in a grid in Price Descending order. Thought I would use getResources / getPages to handle that. It's been a very long time since I've even used those add-ons.



                [ed. note: mmcgee last edited this post 11 years, 7 months ago.]
                  • 3749
                  • 24,544 Posts
                  Selecting or sorting resources based on TV values is very slow, especially as the site grows. Using getResources to do the job is even slower. It's not too bad if you can cache the results, but if it's going to be a dynamic search, you're definitely going to want to get rid of all the TVs and extend the modResource object.

                  http://bobsguides.com/blog.html/2014/06/02/why-extend-modresource/
                    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
                    • 19872
                    • 1,078 Posts
                    Bob: I don't exactly know what I have or need:) One minute, I'm confident... feeling like I'm getting the hang this. And the next, I feel completely lost. Hence my reluctance to jump off and try to learn a completely different approach. At the moment, I'm struggling just to get my TV with checkboxes to output with a ul tag instead of a div.

                    I don't know what you mean by "dynamic search". I would have a landing page that would show a picture of a home, the name of the neighborhood, and a price. Those pictures would be arranged in price descending order. So... I don't know if that warrants going the route of extend mod-resource or not.

                    All in all — there might only be 6 to 18 resources total. I could see if there were going to be maybe 200 or more, things might get a bit sluggish. But with so few resources, am I going to notice that much of a difference?

                    At a later date — I will be bringing in an IDX feed where all "true" searches can occur based on about any word that is associated with a listing. That IDX does not look so great though, and is tough to customize the CSS. So for now — I'm creating a custom look for my client with only her listings. More of a portfolio site, but at least include all the major features of each home.
                      • 3749
                      • 24,544 Posts
                      By "dynamic search," I meant that the site visitor would select either a search or a sort criterion before the properties were displayed. It sounds like you'll be using an external system down the road for that kind of thing, so you may get by fine for now with your TVs.

                      That said, extending modResource is not nearly as difficult as it sounds. You select the fields you want to add to the Resource object (e.g., price, photo_url, bedrooms, bathrooms, sq_footage, view, year_built, etc.). Once you specify them, ClassExtender creates the custom table to put them in and adds the fields to the Create/Edit Resource form for you.

                      From then on, you just put the setResourcePlaceholders tag in the template and use placeholders for any of the extra fields. Once you get it set up, it's *very* fast.

                      The getExtResources snippet works pretty much like getResources, minus a few bells and whistles.

                      If you've got a Cloud account or can set up an extra version of MODX somewhere, you might play around with ClassExtender a little to see if you like it.
                      [ed. note: BobRay last edited this post 11 years, 7 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