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

    First post here. Been using MODx Revo to create sites for clients for the past few years and have a question that I seem to have yet found a solution for.

    I'm not sure if my setup creating a MODx is how other people do it, but usually I put most variables that I want a client to change within a TV. For things such as sliders on pages I'll use a MIGX TV to allow an item to repeat and for other items. For items that need their own sub pages (such as client partners) i'd use collections to keep the documents together and then assign template variables to those.

    The problem I've been having is that using SimpleSearch these TVs aren't searchable. Much of the content that is inside the TV is usually the content that a user would want to search, and so I've been looking to move away from SimpleSearch until it gets TV searching support. I've tried AdvSearch but I can't seem to find any reference to the script that creates an index of the site for Lucene to search so that seems like a dead end.

    Recently I've tried using the ContentBlocks plugin (paid) which allows for various blocks to be inserted into the page and those blocks can have settings similar to template variables. These settings can be inserted into the ContentBlock output template which means that SimpleSearch can find those variables. It works, but that's mainly down to ContentBlocks rendering out the settings to HTML when the page is saved.

    Any thoughts on a better way of doing this, or a way I can get a search module to search TVs?

    Thanks,
    Gareth

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

      • 4172
      • 5,888 Posts
      Its possible to search in TVs with simpleSearch.
      For special use-cases it is also possible to create special search-drivers for simpleSearch.
      Posted one or two somewhere in the forums here.

      Another way is, to render the page-content with a plugin at onDocFormSave into the content-field, just like contentBlocks it does.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • discuss.answer
        You can search TVs using SimpleSearch and its includeTVs property.
        http://rtfm.modx.com/extras/revo/simplesearch/simplesearch.simplesearch#SimpleSearch.SimpleSearch-AvailableProperties

        However, you might be interested in BobRay's ClassExtender.
        http://bobsguides.com/classextender-class.html
        http://bobsguides.com/blog.html/2014/06/02/why-extend-modresource/

        Again, you can search the custom fields with SimpleSearch and its customPackages property.
          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
          • 50544
          • 2 Posts
          Excellent resources, thanks guys!

          I seem to remember trying to search TVs in SimpleSearch a while back but the functionality wasn't there, I'm guessing this is a recent addition?

          The ClassExtender stuff looks pretty interesting so I'll take a read of that, thanks Susan!
            • 3749
            • 24,544 Posts
            If you wanted to devise a system for storing resource-specific data that was *not* amenable to efficient searching and sorting, MODX TVs would be it. The resource TV values are not stored with the resource, but in a separate table, and the TV's default values are in yet another table. Worse yet, when a TV is saved with it's value explicitly set to the TV's default value, no record is created in the table containing the TV values.

            In addition, imagine that you have a resource and want the value of its TV with a default value of &INHERIT for search purposes. First you query the TV values table, but find it empty. Then you have to get the TV object itself with a new query to find out what it's default value is. Once you know that the default value is @INHERIT, you have to call $modx->getParentIds() to get the resource's ancestry. Then, you have to walk up the tree checking TV Values table each time using the ID of one of the resource's ancestors until you find one that's set. Then, you have to search its content. Mind you, this is just for one resource. In a search you'd have to theoretically do that entire sequence for each resource involved in the search.

            Using ClassExtender is more efficient, but you do give up the convenience of things like @ bindings and rendered TVs.

              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