By vnxvnx on
When configuring a block to show only on listed pages, how do I refer to the pages? That is, what "name" or by what format do I refer to a page? I have paths enabled and have used the page alias (url, name, path or whatever I should call it), but that is evidently not correct. Thanks for any help.
Comments
If your intent is to only
If your intent is to only display a block on certain pages, you should use the Page specific visibility settings option on the block settings page.
If, for example, you selected the Show on only the listed pages option, and wanted your block to show up only on two pages, you could add these two lines:
Those two entries represent specific "pages" on your site - your blog page, and your my-new-page page. If you wanted the block to appear on all blog related pages (blog/texas/august/blog-name), you could add another entry in the settings of
that is my intent. however, ...
Thanks. That is what I want to do, and your suggestion of how to do it is indeed what I have been doing.
However, the block in question is not displayed on the named pages. It is displayed on the front page if I write `' in the "Show only on the listed pages" field. But it is not displayed on my paged called (named, aliased) `the_page_name' if I write `the_ page_name' in the "Show only on the listed pages" field. That is why I am at a loss.
Make sure that you have
Make sure that you have indeed checked the box that reads 'show only on the listed pages' and not that box that reads 'show on every page except the listed pages'.
Yes, I made sure of that.
Yes, I made sure of that. Thanks. That is not the source of my problem.
Gonna bump this because I'm
Gonna bump this because I'm having the same problem. I've developed several Drupal sites over the past year and have never had this problem. Now I'm doing a special project for myself and wanted to use Acquia Drupal. Don't know if that has anything to do with it or not.
Anyway, I am all too familiar with restricting a block to a certain page, but now it's just not working. The admin navigation block, for example, displays perfectly. But any block I or an added module created just will not show up on either sidebar. It will, however, show up in other regions, like content top and bottom... but just not in the sidebars.
What's the deal now? Never had this happen before.
I generally have been using
I generally have been using just;
blog*
user/add/blog*
I'm seeing this malfunction myself. And it's serious trouble
I'm seeing this malfunction myself.
I'm trying all the combinations of radio button settings and path constructions.
I've got
pathauto
administration theme (set to garland)
my own zen subtheme
frontpage (as yet unused)
I'm on drupal 6.14 pretty current on php & apache
this could bone my whole current project, which requires multiple themes and a slightly unusual layout.
I will add that adding custom pages to administration theme is also not working.
Weird weird weird.
I found out my problem. I
I found out my problem. I really should have thought of this earlier, but oh well.
My problem is that I didn't think to exclude the Page Specific Visibility block from the editor (in my case, FCK). So try that. Either exclude the path from FCK or switch to plain text and don't use the editor. The problem is that when using the editor, it strips out and adds certain things, like breaks, etc. That interferes with the path. So switch to plain text and enter, for example: page or page/* for all pages to be included or excluded.
This worked for me. Now, all blocks are being displayed where they should be.
Hope it helps!
Chris
Had same Prob, My Solution
I had the same problem happeing to me and it was driving me crazy. None of the replies helped me out, but the last reply by sgprs made me thinking and led me to a solution, at least in my case:
Instead of starting the entry on the first line of the edit box, I entered first a return (just typed the Enter button of the keyb), then I typed in the page I wanted the block to show upon on the second line like this
node/3and then entered two more returns.Et voila, my problem was gone. Apparantly adding these empty lines solved in preventing the editor from messing up the entered path.
Greets,
Hans
Same problem, any other idea ?
Hello,
I have the same problem, do you have any other idea to try ?
Thanks.
Anyone made any progress on
Anyone made any progress on this?
That is
I found solution to this problem following your instructions.
Thanks.
Hans, that worked for me.
Hans, that worked for me. Crazy weird. -Mark
strange but working
thanks .. this worked for me like :)
"Show on only the listed
"Show on only the listed pages" not work if I type aliases like:
but it work if I use node ID:
show block only on listed pages
This worked a treat - thanks astro87! Saved me time and effort, much appreciated.
First off, Thanks...
Secondly I am relieved that this worked and annoyed at the same time. I did a lot of really convaluted and complex solutions to try and fix this problem and that fact that this simple method worked urkes me.
Thanks anyway
Use the node number (e.g.
Use the node number (e.g. node/5) instead of the given name (e.g. my_page) by you.
In order to learn the node number remove "URL alias" from the edit tab of your page, save and check the link of your page from the address bar (e.g. http://localhost/?q=node/5).
Show block on a specific page
We can achieve this in multiple way. Tried this with custom theme preprocess hook and it worked for me.
function mytheme_preprocess_block(&$variables) {
$target_block_id = 'YOUR_BLOCK_ID';
$display_paths = [
'/node/1', // Example path
];
if ($variables['elements']['#id'] === $target_block_id) {
$current_path = \Drupal::service('path.current')->getPath();
$current_path_alias = \Drupal::service('path.alias_manager')->getAliasByPath($current_path);
if (in_array($current_path_alias, $display_paths)) {
$variables['#access'] = TRUE;
} else {
$variables['#access'] = FALSE;
}
}
}