1

I have successfully created content types for certain pages which I have in Drupal. I have also successfully created menus for those content types, so when a user is on a certain type, for instance, Blog Article, they are presented with a certain menu. The problem is when I few all the blog articles the menu is there, but when when I few the /blog page which shows all the blog entries, the content block is gone.

I've set it up so the block will only be shown with certain content types, but there doesn't seem to be a content type of blog module in general. Is there a way around this? It is the same for the forum page. It will show for forum topics, but not for the actual forum.

I hope I've made my self clear, as it is quite hard to explain.

Sententia
  • 625
  • 1
  • 6
  • 17
  • Ok, how did you configure your menu to show on the /blog/article page? I mean, are you doing this through code or the interface? – Stephane Gosselin Dec 21 '11 at 04:52
  • Through the interface. I spoke on the IRC #drupal-support with no luck either. They said the /blog page doesn't have a node type (content type) as it is produced by the core blog module. They also said to give the module Context ago, but it doesn't do what I want to do. It will set the link item's class to active and that is about it. What I want to do is show the entire menu when it is on this page. Gritting teeth with this - slowly getting a headache. – Sententia Dec 21 '11 at 05:43
  • Basically they way I have set it up is, once I have created the menu I then add the menu block to a region. I then configure the menu block to only show on certain content types. There is a Blog Entry type and that is it. It doesn't allow me to specify the blog page. – Sententia Dec 21 '11 at 05:45
  • Ok, what version of Drupal are you using? There is an option in the block configuration page that allows you to enter the pages you want the block to show on. More details in an answer for better formatting. – Stephane Gosselin Dec 21 '11 at 06:44
  • I'm using D7. I've played around with the restrict to path, and used blog/* and blog, but the problem is each blog entry is a node so I can't have it appear also on node/*. If I do I try and restrict it by content type, and then all of a sudden it doesn't show on blog and blog/* as they are not of the content type. This is frustrating as. – Sententia Dec 22 '11 at 01:07
  • I'm thinking to do a hook for blog page, but I'm not too sure with hook system and Drupal (new to it an all). I have set up the function theme_page__blog and that successfully allows me to spit out stuff, but as a result it destroys all the formatting for the page. To get around I'm thinking I need a hook which identifies that it is now on the blog page and it is given a variable (true or false) which is passed to the view. In the view I then call the menu which is needed, which in this case is a sub menu. So some info the hook methods of getting a menu and details through code would be great! – Sententia Dec 22 '11 at 01:11
  • Ah! Then you need the 'expert' option, the one where you show depending on a php condition. Don't let the warning of this fool you, it is the most powerful of the options offered. It is with a custom php condition that you will easily add your 2 conditions for block visibility. If you want to control block visibility without using php, check into [context module](http://drupal.org/project/context). – Stephane Gosselin Dec 22 '11 at 07:44

2 Answers2

0

I do not know what version of Drupal you are using but I will try to help.

As per docs on drupal.org:

Configuring a block

  1. Go to the Blocks overview page (Administration > Site Building > Blocks) to configure the blocks on your site. This page allows you to drag-and-drop blocks into different regions as well as reorder the blocks within a region.

  2. Next to each block you can click "Configure" to change the specific block settings: Block title: Allows you to override the default title for the block User, Role, and Page specific visibility: Adjust visibility for block based on user, role or page. Additional settings may also be available, depending on the particular block.

Note that blocks are configured per theme. If you change the theme or enable multiple themes, you will need to configure blocks per theme.

Yeah. I may of messed the formatting a bit but basically, in step 2, you want to configure your block visibility by page specific visibility. It looks something like below:

Example block configuration

Basically, I think in your case you could use that to show the blocks containing your menus on specific pages and add whatever paths you want your menu to show on.

Hope that helps! Happy coding

Stephane Gosselin
  • 9,030
  • 5
  • 42
  • 65
  • Hey stefgosselin, Thanks, but the I'm using D7. I've tried the restrict by page and content type with no luck. Because the blog is a module there is no content type or node on the page, as I was told in the IRC room. – Sententia Dec 22 '11 at 01:13
0

I figured it out. Instead of trying to display a block based on the content type you have to change it so it is displayed based on the URL. The reason for this is because the blog module which comes with Drupal 7 doesn't have a content type, so when a user arrives at http://www.example.com/blog there is no content type and throws all the blocks restricted by content type out the window.

To get around it I had to install a plugin called Pathauto. This plugin allows you to specify a default URL for a content type. Be sure to install this plugin first before creating any content as any previous URLs will not work, so you will have to manually go back and change the URL alias.

Once you have installed the Pathauto plugin go and setup your paths for content types. I set it up so anything which is a derivative of the content type "Blog Entry" is given the URL /blog/post-name

Now all you have to do to set the block is go to the block and click configure. In the section Pages make sure you select "Only the listed pages". You'll have to type two lines. blog and blog/*

Now that you have set this any new content which is created as Blog Entry will fall under this URL expression and the block will be shown.

Works like a dream now. What a headache to get working.

Sententia
  • 625
  • 1
  • 6
  • 17