i’ve been looking into wildcards for visibility paths primarity so I can add a block into my news/view page without specifying all my news articles.
inside blocks function within croogo component, there is a query which checks the url:
'Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%',
obviously, adding news/* wont match so no block in this instance.
The solution I settled on was to modify the conditions and add another check:
I replaced:
'conditions' => array(
'Block.status' => 1,
'Block.region_id' => $regionId,
'AND' => array(
array(
'OR' => array(
'Block.visibility_roles' => '',
'Block.visibility_roles LIKE' => '%"' . $this->roleId . '"%',
),
),
array(
'OR' => array(
'Block.visibility_paths' => '',
'Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%',
//'Block.visibility_paths LIKE' => '%"' . 'controller:' . $this->params['controller'] . '"%',
//'Block.visibility_paths LIKE' => '%"' . 'controller:' . $this->params['controller'] . '/' . 'action:' . $this->params['action'] . '"%',
),
),
),
),
With:
'conditions' => array(
'Block.status' => 1,
'Block.region_id' => $regionId,
'AND' => array(
array(
'OR' => array(
'Block.visibility_roles' => '',
'Block.visibility_roles LIKE' => '%"' . $this->roleId . '"%',
),
),
array(
'OR' => array(
array('Block.visibility_paths LIKE' => '%"' . $this->controller->params['url']['url'] . '"%'),
array(
'Block.visibility_paths LIKE' => '%"' .
'controller:' . $this->controller->params['controller'] . '/' .
'action:' . $this->controller->params['action'] . '/'.
'type:' . $this->controller->params['named']['type'] .
'"%',
),
),
),
),
),
This then allows the addition of the following in visibility paths
controller:nodes/action:view/type:news
to get our result.
Filed under: code snippets, development, cakephp, croogo