Searching in MODX-extras

Hi there!

I wanted to post some of my thoughts about searching on MODX-sites and in other extras in general.

As far as i know there are two main extras for this task - “SimpleSearch” and “AdvSearch”. Those are able to search in the normal MODX-content, like pagetitle, lontgitle, content etc. Additionally they are both able to search in TVs by using the includeTVs-property - but I rarely (or never?) used this.

But the point why I am writing this is, that none of these search-extras seem to be able to perform a search in other MODX-extras.

  • I first stumbled upon this issue, when I wanted to do a search in entries from the “Glossary”-extra.
  • Then the same happened with the “FAQ-Manager”.
  • And now - for the third time - I’m struggling to do a search on tags I created with the “Tagger”-extra for many resources.

In the old forum are a lot of posts where people are trying to get both search-extras with other extras to work, but I did not find a working solution (for me) yet.

I can’t believe that it always seems a struggle and a lot of tweaking for experts to get this running, instead of working out of the box? Or am I missing something completely?

I already tried a lot on SimpleSearch and FAQ-Manager, as you can see in this post:

All those mentioned extras I do like quite a lot, but I think those are kind of “useless”, when they are not able to perform a search on them.

There’s also mSearch2, a premium extra available from modstore, which I found to be quite impressive. I’m not sure if that supports searching through non-resource content, but it’s definitely worth a shout out here.

For SimpleSearch, I’d probably use a faceted search for any custom search locations. That gives you more control than the customPackages property, but may or may not be suited for how you want your search results to be presented.

1 Like

Thanks for your answer, markh!

The first link to mSearch2 doesn’t tell me whether the extra will be able to perform a search in other extras or not…so i was hoping for the 2nd approach you pointed me to.

But the basic “faceted search”-example from the link you provided doesn’t work either :frowning:

Normally i’d think when I do everything exactly like in the example given, by using the search term “admin” i would get a result…but nothing. Tried it as well with the saved email-adress and fullname, but same => no result…this is very frustrating overall tbh…

I’ve been working on an extra called CustomSearch which will search in all major MODX objects (resources, elements, TV values, users, user profiles). It will do search and replace throughout the site and also regular expression search and replace.

I’m just finishing up the unit tests and documentation so it should be available fairly soon.

I would just like to mention - I really love MODX and I am using it for many years now. I love the open-system and the opportunity to do everything you want to do - as it seems to me. But you have to have the knowledge and skills in order to achieve what you want with a lot of scripting and individual solutions. MODX is my preferred CMS, which I always recommend when someone wants to know my two cents. I think I learned a lot in these past years, whether from the forum or via stackoverflow. But I am still highly limited, as I am now experiencing again while doing these current projects.

Additionally I love the MODX-community and the ongoing will of many to help others on here and back in the old forum. Especially some forum-members, that never gave up helping someone, no matter how hard or easy the task has been. I guess you know the many ones I am talking about…
So I did not want to offend anyone with my statement “kind of useless”! I really appreciate the effort everyone has done by creating an extra. I only can imagine how much work this might be. Or anyone who has even giving a hint or a thought on an issue in the forum. Many thanks for that!

So back to my task…

Inbetween I tried a lot of other things i read in this forum and the old one…tried again several SimpleSearch-ways with the extractSource and customPackages-options, but basically the same as described in my other post on here…

By using this SimpleSearch-call:

    &customPackages=`faqManItem:id,question,answer,set:faqman:{core_path}/components/faqman/model/ =` ]]

and this chunk:

<div class="simplesearch-result">
    <h3>[[+idx]]. <a href="[[+link]]" title="[[+longtitle]]">[[+pagetitle]]</a></h3>
    <div class="extract">
        <p>[[+extract]]</p>  [[+tags:tagsTest]]

i am able to find something with the given search-term “test”. But the last part =

is wrong, because the is not the resource-id, where the FAQ-Manager is held on. So i thought I might be able to predefine the resource ID, where the FAQ-Manager-call is used, and “build” a hash, that contains the FAQ-Manager-entry ID - so that I could be able to click on the result-list-link, get redirected to the FAQ-Manager-page with the correct hash, then scroll to an anchor with that hash. But I wasn’t able to create the hash-part.

But additionally, I am getting all other resources listed which have the same search-term “test” somewhere in the content or pagetitle. The usual [[+extract]] just shows the content of the FAQ-Manager entry, and not an extract of the content like usually…bummer :frowning: Even when I am entering a search-term “welcome”, which is not available in the FAQ-Manager-entry (I only created one for testing purposes), the search-result-entry still contains the content of the FAQ-Manager-entry, not the extract of the content from the resource.

Additionally I just found out, that SimpleSearch does even find inputs, which have the search-term included somewhere.

I used these simple calls:



with the search-term “test”, and I am getting listed a page, that does contain this input field:

<input type="hidden" name="test" value="Customer News">

Shouldn’t be listed in the results-list, or should it? Sure, the search-term “test” is given, but as the name of a hidden input-field…this shouldn’t be listed in the search results in my opinion?

I also found different posts about the Advsearch-extra, like this one and this one, which provided snippet-codes are quite nearly the same…

These looked promising, as the script checks for both needed tables for the Tagger-DB-entries - modx_tagger_tag_resources and modx_tagger_tags. But those solutions didn’t work for me either.

Additionally i tried to enhance the snippet-part to search in the FAQ-Manager-entries and/or the Glossary-entries like this:


$modxTablePrefix = 'modx_';

$taggerModelPath = '{core_path}components/tagger/model/';
$faqManModelPath = '{core_path}components/faqman/model/';
$glossaryModelPath = '{core_path}components/glossary/model/';

    'qhVersion' => '1.2',
    'joined' => array(
            'package' => 'tagger',
            'class' => 'TaggerTagResource',
            'packagePath' => $taggerModelPath,
            'withFields' => 'resource',
            'tablePrefix' => $modxTablePrefix,
            'joinCriteria' => 'TaggerTagResource.resource ='
            'package' => 'tagger',
            'class' => 'TaggerTag',
            'packagePath' => $taggerModelPath,
            'withFields' => 'tag',
            'tablePrefix' => $modxTablePrefix,
            'joinCriteria' => ' = TaggerTagResource.tag'
            'package' => 'glossary',
            'class' => 'Term',
            'packagePath' => $glossaryModelPath,
            'withFields' => 'term',
            'tablePrefix' => $modxTablePrefix,
            'joinCriteria' => ' ='

return true;

but - quelle surprise…no luck…I was too optimistic.

I also tried to only use the glossary-array, and to only use another faqman-array…

        'package' => 'faqman',
        'class' => 'faqManItem',
        'packagePath' => $faqManModelPath,
        'withFields' => 'quesion',
        'tablePrefix' => $modxTablePrefix,
        'joinCriteria' => ' ='

…but no luck again.

At this point important for me is to have a tagging-option for the content-editor to add tags to resources and make them searchable through - preferably - SimpleSearch.

After some more research I tried the Auto-Tag-TV and Tag-TV, which I never used before. On first sight it looked promising as well, although the output-options like “delimiter” or “HTML-Tag” did make no difference. I could manage/style the output with a custom-snippet, but tbh I thought the output-options would help on this.

And woohay - with SimpleSeach and &includeTVs and &processTVs I could even search for those test-tags i enterred via the Auto-TV-Tag. But again, using SimpleSearch does show results with inputs, that have the search-term in their name-property (as described above) - and/or maybe somewhere else as well. And I still cannot search in FAQ-Manager or Glossary…hm…

I also found this thread where (the famous) Bruno mentioned:

I think you could create a extra table, which holds all used tags and a plugin, which actualises its entries by onDocFormSave and some other System-Events

To get the tags into a multiple-listbox-TV you could use a @SELECT or @EVAL-binding
To create new tags, use a extra TV, which you can read by the onDocFormSave - plugin

at frontend you could use rowboat, for example, to get the tags into the tagcloud.

This should generate the tags in frontend and backend much faster.

So the Auto-Tag-TV or Tag-TV do not seem to be the best choice for the use of many different tags…So I am back to point zero and don’t know where to start or tweak or whatever to do…

Hey Bob!

Thanks a lot for the info! I am looking forward to this, it sounds promising.

Does this include extras like Tagger, Glossary and FAQ-Manager as well? Because as I understand, those are not “real” TVs or elements, “just” db-entries which are getting combined and handled different…?

I don’t want to be greedy though! :wink: I am quite sure this will be a top extra, as many (if not all) of your others are! I am just not using every one of yours :wink:

Thanks for your work and help!

Thanks for the kind words.

CustomSearch won’t find things in custom DB tables, since it doesn’t know they exist. That said, I’m not familiar with the extras you mention, but there’s a good chance that some of them store their values in chunks or in the modTemplateVarResource table. If that’s the case, CustomSearch would search them.