Expand Drupal menu by default - drupal

For the menu system, is there a way to set one of the menu items to be expanded by default? I can't get my home menu item to be expanded on the homepage (at the least), and I'd like it to be expanded whenever one of the other ones isn't.
I'm using Drupal 5, and the Taxonomy Menu module. Taxonomy Menu is pretty good with 95% of my pages, but some are static "About Us" type pages, which I'd like to have the home menu as default for, and then there's the homepage.

Well, I think I found a (sad) answer. From an issue on the Drupal webpage, "as it appears, the menu system of Drupal 5 is broken and won't be fixed anymore". So I'm finding a new way to do the top navigation that goes outside of Drupal's menu system.
Solution:
I ended up putting the navigation system in page.tpl.php. Based on the content of the nodes (I'm pulling the taxonomy from the breadcrumb), it chooses which one is highlighted, but defaults to home. It's hackier than I'd like, but it works.

/**
* Implementation of hook_menu_link_alter().
*
*/
function module_menu_link_alter(&$item, $menu) {
if($item['menu_name'] == 'primary-links') {
$item['expanded'] = 1;
}
}

It might be worth upgrading to Drupal 6 if you don't have too much invested in Drupal 5. Then all you have to do is administer the relevant menu and tick the "Expanded" option for it...

Related

Blog posts not highlighting the active menu item

Ok, I know that there are several other questions on SO regarding this topic. By now, I have probably read all of them. I have been researching this for a little over two hours now and I am coming to the end of the road (about to give up!)... So, here I am on SO finally asking the question to involve other sharp minds.
I am helping build this Wordpress site: greatman.us. And, the Posts page is located on a page called "Blog." The "active" menu item is highlighting properly on PAGES, but when you go to a POST, the "Blog" menu item is not longer highlighted (i.e. NOTHING is highlighted in the header menu).
There is no way in Wordpress - as far as I'm aware - to create a "parent" for a blog post. This option is only available for Pages. I need to be able to have the "Blog" menu item stay highlighted when I am viewing a BLOG POST.
For a general example:
mywebsite.com/blog/ <--- menu item "Blog" is highlighted
mywebsite.com/blog/post223 <--- menu item "Blog" is no longer highlighted
I am proficient with CSS and HTML, but not with PHP. So, if this is a PHP fix, please dumb your answer down as much as possible.
I have read tons of other articles about this online and it seems to be a common issue, with most people not knowing how to code with PHP.
I am using a custom theme, called Divi. And it is missing some of the CSS elements that other forums and sites I have read said that the style.css should have. This is another reason I am coming to a dead end. Please help!
By the way, one WORKAROUND I discovered is to add POSTS as sub-menu items to the "Blog" page that you made in the Wordpress Menus area (in the admin back-end). Then, use "display:none" is CSS to remove the submenu from being displayed to the public. This causes two main problems, though: 1) You can never have any other sub-menu items, because they won't be displayed. 2) You have to manually add every single blog post to the menu as a sub-menu item. This will eventually make your menu super long assuming you are a regular blogger. It is also a hassle.
Within your CSS, you will also need to add .current-page-ancestor with the same attribtues as your current menu item.
Something similar to below:
.current_page_item, .current-page-ancestor {
// Some attributes
}
This is guessing that you have use wp_nav_menu() though. If not then I'll need to see what code you have used to generate the menus.

How can I hide pages from menus in WordPress?

I only want to show the pages that do not have parents, and link the other pages from their parent pages.
I want to have a simple main menu: Home | Pages | About | Contact
About 8 pages are linked from the Pages page. At the moment, the menu has 12 items, which deforms the layout pretty badly.
I have tried making the pages private, unpublished, and other options, but that doesn't seem to be the way to do it. Is there a way I can just have only parent pages linked in the main menu?
You can edit the menu (under the appearance tab in the dashboard). (you may need to add a new menu and assign it to the main navigation menu. It sounds like you have the defaulted menu set-up.
Once you've added a menu and assigned it to the main navigation, you can uncheck "automatically add top-level elements" or its equivalent, and add/remove menu items. You can also change their hierarchy (independent of actual page hierarchy).
It's all so easy these days. Just Go to appearance>menus>click the little triangle next to the listed page name>click remove> don't forget to save ... all done!
Maybe you didn't set up a custom menu yet. Set up a custom menu first with the desired pages / links. If it doesn't show on your site, check custom memus are enabled in your theme.. this will help you setting up a custom menu: http://www.wpbeginner.com/wp-themes/how-to-add-custom-navigation-menus-in-wordpress-3-0-themes/

Drupal 7, subpages not showing up

I have pages that I've organised to be under another main page but it isn't showing up under the secondary menu.
How do I get the secondary menu to display child pages of the current page?
Would there be a theme that does this already, i've tried zen and stark but they don't list the pages organised under the current page.
This sounds like a bug that I've run into myself: Custom menus never receive an active trail
I've explained a workaround in a duplicate issue.
To sumerize:
The problem is that Drupal core active trail, breadcrumb and menu expansion only work for a set of core menus, defined as:
$menus = variable_get(
'menu_default_active_menus',
array_keys(menu_list_system_menus())
);
There is no interface to change this, but you could do it in your settings.php and add the names of the menus you have created. Not a practically solution, but at least it works. You don't usually create new menus that often, so should be fine. An example of what to put in your settings.php file:
$conf['menu_default_active_menus'] = array(
'navigation', // Core menu
'management', // Core menu
'user-menu', // Core menu
'main-menu', // Core menu
'menu-products', // Custom menu
'menu-custom-menu', // Custom menu
);
The Menu Block module works well for displaying the kind of sub-menu you're describing. The module's administration page has lots of options though, so it can take a while to tweak it to get just what you need.

Drupal removes a page from menu links after page edit

This might be a really simple thing but i was unable to find an answer to it. The issue is this:
I'm using Drupal 7, updated from Drupal 6. I have main menu to which i've assigned some pages. Whenever i edit one of those pages Drupal, for some reason, removes it from the menu links. Anyone ever had the same problem or would anyone have any ideas as to why it behaves this way?
Ok, let's try to rule some things out. You said that you assigned this menu to some pages. If you are viewing the page in view mode, then click edit, then save, you will be taken back to the view of that node. If you are viewing all of your content in the admin, then click edit by the node, then click save, you will be taken back to the list of content in the admin. Take a look where you assigned this menu to, AND/OR where you did not assign it to. Make sure you are not looking at a page where the menu was not assigned to.
You only needed to enable it from the settings - 'Provide a menu link'.

2 breadcrumbs for 2 menus in Drupal

I'm using 2 different menus in 2 different blocks. They are enabled / disabled depending on the the pages users arevisiting.
Now, I have an issue with the breadcrumbs: they only work with the main menu and not the second one.
I need to automatically have the breadcrumbs the other menu as well.
thanks
Drupal's menu system sets only one active menu at a time: if you're trying to have two breadcrumbs at the same time on the same page, you're going to need to use menu_set_active_menu_name() to do some juggling back and forth.
However, if you're just trying to have one show up, consider using the Menu Breadcrumb module, which automatically sets the active menu based on the page. You also have the ability to set menu priority for pages that exist in more than one menu.
This question is not strictly programming related, however:
Drupal breadcrumbs follow the menu-items as they are enabled. Regardless of whether the menu-items are visible, and regardless of what menu(containers) hold the menu. Items that are not in the menu (such as nodes!) will not have a breadcrumb.
That said, there is an exception, modules can override the breadcrumb with drupal_set_breadcrumb(), if they do so, the last one to set the breadcrumb gets to set the breadcrumb. E.g. taxonomy module sets the breadcrumb on taxonomy-pages.
You could set the breadcrumbs hardcoded in a module.
You should investigate why breadcrumbs don't follow your menu's in this case.
You could investigate modules that allow tweaking the breadcrumb behaviour, such as hansel

Resources