MODX Community

SimpleSearch - customPackages - search in "Glossary" and "FAQ Manager" extras

Hi there!

I’m using the lastest MODX 2.7.2 with

  • SimpleSearch 2.1.2,
  • Glossary 2.4.1
  • FAQ Manager 2.00-rc3.

SimpleSearch is working fine on the usual fields, but I need it to search inside the items of the mentioned extras Glossary" and “FAQ Manager”.

In the SimpleSearch-docs there is descibed how to search in custom tables:

Searching custom tables is available in SimpleSearch using the &customPackages property; however, you must have a custom package built for it. The format is:

className:fieldName(s):packageName:packagePath:joinCriteria||class2Name:fieldName(s):package2Name:package2Path:join2Criteria

The example provided there is based on the Quip-Extra.

Here’s what should be added to search inside the Quip-Comments:

&customPackages=`quipComment:body:quip:{core_path}components/quip/model/:quipComment.resource = modResource.id

I tried to do this for the FAQ Manager like this:

&customPackages=`faqman:answer:faqman:{core_path}/components/faqman/model/:faqman.resource = modResource.id`

But this did not work.

More detailled information is provided on the doc-site as well:

  • className - The class name of the table you want to search. Here, it’s QuipComment.
  • fieldName(s) - A comma-separated list of column names to search. We did ‘body’, you could also have done ‘body,email’ or whatever.
  • packageName - The name of the schema Package to add. This one is called quip.
  • packagePath - The path to the model/ directory where the package is located.
  • joinCriteria - The SQL to join the table you want to search and the modResource table. Your table must have some connection to the Resource it’s on (otherwise SimpleSearch won’t know how to load a URL for it!)

Once you’ve added it, it will search those fields as well for data. If it finds it in that table, it will display the result as a link to the Resource you specified in your joinCriteria. In our example, that would be the resource the Quip comment is located on.

className:

In the example “quipComment” is used as the className.

But in another install where I used MODX with Quip, I can’t find any table called “quipComment”, just “quip_comment_notify”, “quip_comments”, “quip_comments_closure” and “quip_threads”. So I don’t know where the “quipComment” comes from?

The FAQ Manager tables are called “faqman_items” and “faqman_set”. The relevant table is the “faqman_items”, so I tried “faqman” and “faqmanItem” as well as “faqmanItems”, but no success. So I’m a bit lost at this point already…

fieldName(s)

In the example “body” is used as the fieldName. This is a column inside the table “quip_comments”.

So for me the relevant columns are “question” and “answer”. I tried both, but without success as well.

packageName

In the example “quip” is used as the packageName, so I have to use “faqman”.

packagePath

In the example “{core_path}components/quip/model/” is used as the packagePath, so I have to use “{core_path}/components/faqman/model/”.

joinCriteria

This one I don’t get right I guess.

In the example “quipComment.resource = modResource.id” is used as joinCriteria. In the table “quip_comments” is a column called “resource”, so this I understand.

In my case I want the results based on the FAQ Manager entries always linking to the same resource (on this resource there are all created FAQs displayed).

Same for the Glossary-extra:

There is only one table created called “glossary”. The relevant columns are called “term” and “explanation”. The “21” i used for the “joinCriteria” is the resource the glossarygets diplayed.

I tried different things, ended up with this:

&customPackages=`glossary:explanation:glossary:{core_path}/components/glossary/model/:21 = modResource.id`]]

But still no success.

So does anyone has used the customPackages with success and has a hint for me?

Greetings to the forum!

Ok, I did a little bit of progress…

For the “FAQ Manager”-extra, this code mainly works:

[[!SimpleSearch? 
&tpl=`mySearchResult` 

&customPackages=`faqManItem:answer:faqman:{core_path}/components/faqman/model/:faqManItem.id = modResource.id` ]]

My only problem right now is to tell the in “joinCriteria”-part, that the script shouldn’t grab the “faqManItem.id” as the “modResource.id” - it shall use a static value of the resource, where the link should go to (22 in this case).

Same for the “Glossary”-extra:

&customPackages=`Term:explanation:glossary:{core_path}/components/glossary/model/:Term.id = modResource.id`

Here also it should be a static link to a resource (21 in this case).

The correct name for the “className” is stated in the schema.xml-file that belongs to the package.

For the “FAQ Manager” it’s:

<object class="**faqManItem**" table="faqman_items" extends="xPDOSimpleObject">

For the “Glossary” it’s:

<object class="**Term**" table="glossary" extends="xPDOSimpleObject">

So next step, finde the correct way to statically link to an given resource-id for each customPackage.

ok, that was easy:

&customPackages=`Term:explanation:glossary:{core_path}/components/glossary/model/:21 = modResource.id`

Simply add the resource-id before the equal-sign.

For both packages the customPackages-part looks like this:

&customPackages=`faqManItem:answer:faqman:{core_path}/components/faqman/model/:22 = modResource.id||Term:explanation:glossary:{core_path}/components/glossary/model/:21 = modResource.id`

Still something to do - if possible…

The search-result page outputs the pagetitle of the resource I defined in the “joinCriteria”-part.

It would be great if the linktitle would not be the pagetitle of the resource I defined, it would be better to have the content of the “question”- or “term”-column as the linktitle. Best solution would be to have both - content of “question”- or “term”-column plus the pagetitle afterwards…

I guess this can be accomplished somehow…I’ll dig deeper…