I am mikek's Blog

The personal blog of Mike Karthauser, who you may know from Brightstorm Limited or the internet.

Dealing with wildcards in croogo

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.

Advertisements

Filed under: code snippets, development, ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

mikek on twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

%d bloggers like this: