Skip to content

In &customPackages, add support for custom table prefix #50

@Mark-H

Description

@Mark-H

A client asked for help implementing a search that also includes searches through Lingua translations. While I got the following package definition per the docs and some debugging:

[[!SimpleSearch? 
    &customPackages=`linguaSiteContent:pagetitle:lingua:{core_path}components/lingua/model/:linguaSiteContent.resource_id = modResource.id`
]]

... it doesn't work because lingua requires the package to be added with the table prefix. The package itself doesn't specify it, so the addPackage call needs to support that. It's a bit of an odd way to handle table prefixes in my opinion, but alas, it's a valid supported one in MODX.

In core/components/simplesearch/model/simplesearch/driver/simplesearchdriverbasic.class.php, I had to add the tablePrefix like this around line 91:

        $tablePrefix = $this->modx->getOption('lingua.table_prefix', null, $this->modx->config[modX::OPT_TABLE_PREFIX] . 'lingua_');
        $this->modx->addPackage($package[2], $package[3], $tablePrefix);

That obviously breaks on the next upgrade and also doesn't support using different packages.

Would be ideal if SimpleSearch were to be updated to support specifying the tableprefix, perhaps as an optional 6th argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions