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

Add extra include/exclude filters for Templates & Contexts. #25

Open
Quentin100 opened this issue Jan 22, 2025 · 0 comments
Open

Add extra include/exclude filters for Templates & Contexts. #25

Quentin100 opened this issue Jan 22, 2025 · 0 comments

Comments

@Quentin100
Copy link

I needed to be able to add the plugin only on certain pages, but there were a lot of them, as it was a list of events, and there are a lot of pages that would be excluded as well, and both lists would grow over time.

As such, I figured out I could restrict the Plugin basedon the Templates used (the one for the events and the one I used to "switch" to). I added the below code to the top of the plugin, and it worked (ModX 3.10), but I though it might be better if this was built into the CMP options, and then it wouldn't get overwritten on future updates. Also I don't know if it is the fastest way of doing it as well. Also, I often use multi-context setups, and it would be good to have a "Context" filter if need be, so that I don't use it on all contexts. Again, I could do that in the Plugin, but would have to re-add it every time I update this plugin.

Added code:

$template =  $modx->resource->template;
$allowed = array(5,7);

if (!in_array($template, $allowed)) {
  return;
}
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