Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Mark-H opened this issue Feb 10, 2021 · 0 comments
Open

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

Mark-H opened this issue Feb 10, 2021 · 0 comments

Comments

@Mark-H
Copy link

Mark-H commented Feb 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant