简体   繁体   中英

Drupal Block display not showing on a module page

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.

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:

示例块配置

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM