tags:

views:

94

answers:

2

I'm having a little trouble controlling page-specific block display in Drupal...

My URL's will be of this typical structure:

http://www.mysite.co.uk/section-name/sub-page/sub-sub-page

The 'section-name' will effectively be fixed, but there will be many sub-pages (far too many to explicitly reference).

I need to somehow control block display as follows:

One block will show on all pages where URL contains 'section-name/sub-page' but not on pages 'section-name/sub-page/sub-sub-page'

Conversely, another block will show on all pages where URL contains 'section-name/sub-page/sub-sub-page' but not on pages 'section-name/sub-page'

My only idea is to do a bit of PHP that looks for the string 'section-name' and then also counts URL parts (or even the number of slashes). Not sure how to implement that though :)

Your help would be appreciated!

+5  A: 

You can use asterisks and slashes as wildcards for the level of hierarchy. For example, to only show a block when you're on a page that's 3 levels deep, you'd do:

/*/*/*/

Or you can add the section name before that, like:

section-name/*/*/
stephthegeek
Woah, I did wonder if this was possible, but I couldn't find any indication that it was. Cool, thanks!!!
james6848
A: 

As an addendum, I've found this still requires a bit of PHP to allow you to both include and exclude pages at the same time. I found this bit of code that allows this at http://www.kirkdesigns.co.uk/make-drupal-block-visible-entire-site-sections-not-specific-sub-sections-or-pages

james6848