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

    I am using SimpleSearch on a site which is great, but in the results can't display a TV for the summary content, it can only read the [[*content]] field - therefore, I am looking for a way to automatically make the [[*content]] field on a page mirror the content of a specified TV - is this possible?

    e.g. if TV [[*Example]] was <p>Hello</p>, then I would like the [[*content]] field to automatically get populated with the same content as the TV [[*Example]] - thus it would be <p>Hello</p>.

    Is this possible? If so... how?

    Thanks.

    dubbs
      • 30585
      • 833 Posts
      In version 1.9, you can specify the &extract property to come from a TV. Simply add &includeTVs=`1` to your call and change or add &extractSource=`your_tv_name`. This work.
        A MODx Fanatic
        • 8168
        • 1,118 Posts
        Thanks Treigh - Yeh I had found that since posting this, but the issue I have, is that I have many different TVs which would need to be the extractSource - so it does not solve my issue - e.g. on different page types, the content I want included in the search results summary changes, on some pages its [[*content]], on others its [[*ExampleTV]] and on others for example its [[*AnotherTV]] - so using the [[*content]] field for the extractSource works best - but I need a fix to allow the [[*content]] field to be set to pull from a TV on the pages that I am not using the [[*content]] for the content I want the search results to pull from.
          • 3749
          • 24,544 Posts
          How about a plugin connected to OnParseDocument. You could replace the tags manually before MODX parses them.
            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
            • 8168
            • 1,118 Posts
            Bob, if you think that will work - then it sounds good to me... any tips on how to achieve such a thing?
              • 30585
              • 833 Posts
              While we're waiting for BobRay's insightful take, have you tried the showExtract option? Heres' how this property is defined in the docs: "Show the search terms highlighted in one or several extracts. String as "n : comma separated list of fields". n : maximum number of extracts by result. The search term is searched in the concatenated fields."

              I haven't personally used it, but it almost sounds like what you want.

              Assuming &includeTVs is set to 1, I'm guessing it could be used like this:
              &showExtract=`1:content,1:myTV,:1:myOtherTv`
                A MODx Fanatic
                • 8168
                • 1,118 Posts
                Quote from: treigh at Mar 18, 2015, 10:15 PM
                While we're waiting for BobRay's insightful take, have you tried the showExtract option? Heres' how this property is defined in the docs: "Show the search terms highlighted in one or several extracts. String as "n : comma separated list of fields". n : maximum number of extracts by result. The search term is searched in the concatenated fields."

                I haven't personally used it, but it almost sounds like what you want.

                Assuming &includeTVs is set to 1, I'm guessing it could be used like this:
                &showExtract=`1:content,1:myTV,:1:myOtherTv`

                Thanks Treigh - but that looks like a property for AdvSearch and not SimpleSearch??? I am using SimpleSearch as AdvSearch does not seem to work... makes the search facility fall over!
                  • 8168
                  • 1,118 Posts
                  Quote from: BobRay at Mar 18, 2015, 03:18 PM
                  How about a plugin connected to OnParseDocument. You could replace the tags manually before MODX parses them.

                  Hi Bob, OK - so approach would be this yeh?

                  $modx->resource->set('content', '[[+ExampleTV]]');


                  How do I call in the contents of the TV though? This seems not to work...

                  I will also need to be able to set this plugin to work only on specified resources, e.g. Children of Resource IDS, 1, 3 and 5 for example. And set individually for each resource which TV to use...

                  Possible? [ed. note: dubbs last edited this post 11 years, 6 months ago.]
                    • 30585
                    • 833 Posts
                    Sorry about that dubbs, I completely missed it. Too much coffee taken late isn't apparently good for my brains.
                      A MODx Fanatic
                      • 3749
                      • 24,544 Posts
                      I'm guessing here somewhat, but I think the plugin code would be this two-liner (connected to OnParseDocument):

                      $content = $modx->resource->getTVValue('ExampleTv');
                      return '';


                      This would require MODX 2.2 or greater.



                        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