Skip to content

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

@Quentin100

Description

@Quentin100

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;
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions