Blog Sections Open

Making AjaxSearch Work with Easy2Gallery Data

AjaxSearch is often treated as a document-only search layer, but older projects also needed it to search structured addon data such as Easy2Gallery records. The original solution here was to define a custom data source f

AjaxSearch is often treated as a document-only search layer, but older projects also needed it to search structured addon data such as Easy2Gallery records. The original solution here was to define a custom data source for the gallery table.

Example Structure

[!AjaxSearch? &whereSearch=`easy2`!]
function easy2(&$main, &$joined) {
    $main = array(
        'tb_name' => 'digimonworld_easy2_files',
        'tb_alias' => 'e2g',
        'id' => 'id',
        'searchable' => array('alias','summary','tag','description'),
        'displayed' => array('alias','summary','tag','description')
    );
    $main['filters'][] = array(
        'field' => 'status',
        'oper' => '=',
        'value' => '1'
    );
    $joined = NULL;
}

Main Takeaway

Search becomes much more useful once addon data is treated as first-class content. The key is to describe the searchable table clearly instead of trying to force everything through the default document model.

Newer post

Understanding includeDocs and IDs in Wayfinder Menus

A practical explanation of how includeDocs affects Wayfinder output when menus are built from a hand-picked set of resource IDs.

Older post

Listing Template Variables by Category with a Reusable tvs Snippet

How to build a helper snippet that outputs template variables by category and skips empty or excluded fields.