We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17548
    • 74 Posts
    While I have been a long-time supporter of Modx, because I am not a developer and therefore am unable to understand how the building blocks of modx translate into workable solutions, I am still often unable to think of the 'right' way to solve a specific problem like the one that follows:

    My client's website has sponsors. These sponsors are represented by hyperlinked logo images (jpg/gif/png) that are currently added by my client through TinyMCE into a single resource. I simply include that resource in my template and it displays the way I want it to.

    However, I want to be smarter about this and I started thinking this way:


    • what if each sponsor logo was represented as a static resource in the tree under a sponsor element node?
      The static resource would use a template that did not have any html output, but would have a number of associated tvs that would let the client put in the sponsor name, the url to link to when you click on the sponsor logo, etc.

      The client would maintain the list of sponsors as resources and I would then generate my sponsor bar using getresources or wayfinder.

    So, here's the problem:

    I don't know whether static resources can work this way. There's no default image content type and I don't really want my client to have to declare a different content type depending on the logo image they have because that's asking too much of them.

    Has anyone done something similar to this, or approached it in a different way that works better?

    Am I missing some glaringly obvious way to do this?

    Thanks in advance.



      • 22427
      • 793 Posts
      In my opinion it is a natural way to have each sponsor information in an own resource, being a child of a "Sponsors" page, and to use getResources or Wayfinder to list them. There shouldn't be a problem using static resources - they may be just normal resources, their content being saved in the database. You would use a special template for these resources and TVs assigned to it, so for the logo image etc.
        • 17548
        • 74 Posts
        Thanks ottogal

        I'll give it a try. My only concern is that I don't want to make it cumbersome for my users to add the static resource, and I'm not very familiar with how to create new content types for these resources. As far as I can tell, the way you set the static resource content type means that my editors would have to set a different resource type for png/jpg etc. when they add a new image. I can't do that to them. An image is an image is an image to a content editor. If I use a regular resource and have them insert the image using an rich editor, then I have to worry about HTML that I don't want in there.
        The last solution I can think of is that each resource has no content at all, and the image is set as a template variable. This strikes me as extremely inefficient from a processing perspective, but maybe it's not. It feels hacky though, and if I wanted hacky, I'd use Wordpress purely for its media management, which Modx kinda sucks at.
          • 22427
          • 793 Posts
          The last solution I can think of is that each resource has no content at all, and the image is set as a template variable.
          That's the way I would do it.
          Why do you think this is inefficient?
          For me it's not hacky - this is a case TVs are made for.

          As far as I can tell, the way you set the static resource content type means that my editors would have to set a different resource type for png/jpg etc. when they add a new image.
          There is no need of new resource types.

          Use a TV of Input Type Image, so the editor will see the tree of the File system and can choose the image for the page he is editing.

          If the Output Type is Image too, to insert the image in the template you just need [[*TVname]].

          In the case you set the Output Type to Default, the output will be the (relative) URL of the image, so you would insert an image tag with the possibility to add other attributes you may want:
          <img src="[[*TVname]]" alt="logo" width="200" height="120"  />
            • 17548
            • 74 Posts
            Thanks again.

            I guess it feels hacky to have a resource with no content just for the benefit of the tv (I think of the TV kind of like metadata, but that's not really correct). I think I get it. I am proceeding this way and it seems to be working.

            Thanks for your help.

              • 28042 ☆ A M B ☆
              • 24,524 Posts
              You can use a MIGx TV to provide for more detailed information accompanying the image, including URL if you like. It will also allow re-ordering of the list of sponsors. Have a resource called "Sponsors"; the user may want to have a page dedicated to listing his sponsors.

              http://rtfm.modx.com/display/ADDON/MIGX
                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
                • 17548
                • 74 Posts
                Thanks Susan:

                Had no idea this existed, though reading the description of the addon, I would have had no idea that's what it does.

                I tried to install it on my test 2.2.6 install and it failed. I'll have to dig into it a bit more.

                Thanks
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  You can use MIGx for any kind of variable-length list of objects and all of that object's supporting data.

                  The TV's input fields can be divided up into tabs, and are based on embedded regular TVs (and can include embedding other MIGx TVs).

                  The editing display is a grid, with an "Add Item" button and right-click context menus for editing existing items. The grid list is drag-and-drop orderable, as well as sortable on any of the grid-displayed fields. With MIGx the value is stored as a JSON string. With MIGXdb, the storage is either a custom db table, or the site_resources table.

                  Front-end display is eased with a handful of included snippets, or can be done with a custom snippet to either parse the JSON string of MIGx, or access the relevant database table for MIGXdb.

                  As far as installation goes, I've never had a problem, so I don't know what to say.
                    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