Reputation: 75
I'm trying to display a Joomla module or a div, but only on specific subpages.
Example: trying to display this
<div><?php echo $this['widgets']->render('module'); ?></div>
Only on www.example.com/products/item1
and other subpages of /products
But NOT on:
www.example.com/
or
www.example.com/products/
I can't find a PHP or JS script to do that, nor is it possible to do it with the native Joomla features.
How to do that?
Upvotes: 0
Views: 167
Reputation: 9146
You can use preg_match
on the $_SERVER['REQUEST_URI']
:
<?php if (preg_match("/products\/.+/", $_SERVER['REQUEST_URI'])): ?>
<div><?php echo $this['widgets']->render('module'); ?></div>
<?php endif; ?>
The expression /products\/.+/
sees if products
is in the url and a slash and some content follows it.
Upvotes: 3