I am developing a site with Drupal 7. I have styled the menu correctly and all this stuff. The problem is with the secondary menu.
My idea is to create the second menu immediatly behind the first menu, for example:
MENU_ITEM1 | MENU_ITEM2 | MENU_ITEM3 | MENU_ITEM4
MENU_ITEM1_SUBITEM1 | MENU_ITEM1_SUBITEM2 | MENU_ITEM1_SUBITEM3
And the structure goes like this:
MENU_ITEM1
MENU_ITEM1_SUBITEM1
MENU_ITEM1_SUBITEM2
MENU_ITEM1_SUBITEM3
MENU_ITEM2
MENU_ITEM3
MENU_ITEM4
1st problem, I cannot see secondary items
2nd Any suggestion on how to create this?
Thanks a lot!
You can structure your menu with multiple levels within drupal, and select that menu (e.g. main menu) as the source for both your main links and secondary links, over at "/admin/structure/menu/settings".
Then you can implement drupal's theme_preprocess_page() function in your template.php file:
function themeName_preprocess_page(&$vars) {
if (isset($vars['main_menu'])) {
$vars['primary_links'] = theme('links__system_primary_menu', array(
'links' => $vars['main_menu'],
));
}
else {
$vars['primary_links'] = false;
}
if (isset($vars['secondary_menu'])) {
$vars['secondary_links'] = theme('links__system_secondary_menu', array(
'links' => $vars['secondary_menu'],
));
}
else {
$vars['primary_links'] = false;
}
}
Now all you need to do is echo/print the new variables ($primary_links & $secondary_links in this case) now available to page.tpl.php.
Not all drupal themes allow you to style your menus like this.
If you have a theme that supports nested menu structures, you just need to nest your menu items in the menu settings. Fortunately, drupal handles this relatively well thanks to the drag and drop interface, you just need to make sure that any of your top level menu items have the "expanded" box checked.
If you would like to see a quick example, you can just look at your "navigation" menu settings, they are already nested and expanded, so you'll know what your main menu settings should look like.
Related
I have the issue that one of the pages in a TYPO3 (11.5.20) environment contains dozens of subpages, which would overly extend the HMENU displayed on the frontend. The suggestion by a colleague was to hide all the subpages in said menu and instead display them on a separate menu embedded on the page itself. This basically means we have to make the subpages hidden for only one specific menu, not for all of them, ruling out the possibility to hide the subpages for navigation by the backend.
To have this functionality not just applying to a single, statically defined page, my idea to approach this would be to register a separate page layout for pages with this requirement and somehow configure HMENU in Typoscript to ignore subpages of that given layout. What I found is the itemArrayProcFunc for processing menu arrays; what I would do is to simply return an empty array with it if said page layout applies. I am encountering two problems though:
The function I have defined seems not to get called. I am including the script like in the Typoscript snippet below, but even when deliberately throwing an exception inside, there is no feedback on it whatsover by TYPO3, with the menu displaying all pages as usual. Is that method of inclusion possibly outdated? The official TYPO3 doc dictates USER and USER_INT for registering custom functions, but I'm not exactly sure how to make this work together with itemArrayProcFunc.
Even if the function worked, I'm not sure how to retrieve the layout of the respective parent page, or if it is even possible to retrieve it at all.
I'm assuming there are some major points regarding custom functions within Typoscript I might have missed (to be fair though - TYPO3's documentation is not exactly transpicuous). Could anyone possibly give me a hint on it? Is there maybe even a more elegant way to hide menus from specific pages?
lib.ts (snippet):
includeLibs.user_menuItemArrayProcFunc = EXT:lraffb_intern/Classes/MenuItemArrayProcFunc.php
lib {
...
20 = HMENU
20 {
stdWrap {
outerWrap = <nav class="navigation">|</nav>
}
entryLevel = 0
1 = TMENU
1 {
wrap = <ul>|</ul>
NO = 1
NO {
allWrap = <li>|
wrapItemAndSub = |</li>
itemArrayProcFunc = user_menuItemArrayProcFunc->process
}
ACT < .NO
ACT {
allWrap = <li class="act">|
}
}
2 < .1
3 < .2
4 < .3
5 < .4
}
...
}
MenuItemArrayProcFunc.php:
<?php
class MenuItemArrayProcFunc {
public function process($menuArr, $conf) {
if (PAGE_LAYOUT == 'pagets__left_no_subpages') // retrieve the page layout here somehow
return [];
return $menuArr;
}
}
This basically means we have to make the subpages hidden for only one specific menu, not for all of them, ruling out the possibility to hide the subpages for navigation by the backend.
Well - actually this is the solution you are looking for but just the other way around. Set those pages to hide in menus and then use the includeNotInMenu parameter to still use them in all menus except the one you mentioned.
https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/ContentObjects/Hmenu/Index.html#includenotinmenu
Depending on a flag (that could be the page layout) you should differ the rendering of menus. That would be easy if you render your menus with FLUID as you can insert conditions in an easier way than in TypoScript.
e.g.: Depending on your condition you render the second level or skip it.
On page rendering you have all fields from pages record, including your flag. When you call the menu partial just remember to insert the flag in the arguments.
I have a website with the following setup:
overview.php
hotel1.php
hotel2.php
hotel3.php
Where overview has a sidebar with links to hotels 1, 2 and 3 and each hotel page has a sidebar with links to the other two hotels (excluding itself) along with the overview page.
At the minute, I am hard coding the sidebar in each php page, as they are all slightly different.
I am wondering if there is a way I can code one sidebar in a separate file (sidebar.php) with links to each of the four pages and add the sidebar with a php include() function.
Then, depending on the page (which will have an identifier), show all the links, except the link to itself.
Problem is, I'm not sure how to do it, or if it can be done.
The site is php and html (with css and javascript).
And if it is relevant, I have about 100 folders containing an overview and then multiple hotels which I would like to implement this on.
The easiest way to do it is to wrap your sidebar code in a function.
sidebar.php
<?php
function print_all_sidebar_links_except_self($self = NULL){
$hotels_text = array(
"hotel1" => "Gryffindor Tower",
"hotel2" => "Ravenclaw Tower",
"hotel3" => "Slytherin Dungeons"
);
if (isset($self)){
unset($hotels_text[$self]);
}
foreach ($hotels_text as $page => $name){
echo "<a href='".$page.".php'>".$name."</a>";
}
}
?>
overview.php: print_all_sidebar_links_except_self();
hotel1.php: print_all_sidebar_links_except_self('hotel1');
hotel2.php: print_all_sidebar_links_except_self('hotel2');
hotel3.php: print_all_sidebar_links_except_self('hotel3');
the website in question is right here I'm trying to generate a CSS dropdown, however no such option is available in wp_list_pages(), I also won't be able to get the desired effect using WP Menus in the appearance menu (I used this method to generate my footer links)
This is ideal:
I know how to generate the menu, I just don't know how to get it under the "cars" menu without a hack javascript solution.
The ideal solution involves targeting the list item by the template name "Car Showcase" and allowing me to generate PHP/HTML (The code needed to make the dropdown) after it. Does this make sense to everyone?
The actual way to create custom HTML for WordPress menu is to create a Walker
http://codex.wordpress.org/Function_Reference/Walker_Class
Can you not just create another menu and pull it from:
wp_nav_menu( array( 'name' => 'menu-header'));
I extended the walker class in functions.php, it was way dirtier than it should be, and I'm still targeting the list item being generated by an ID, a solution which I am not fond of, but this is the cleanest solution I can come up with until I find a better one.
class Dropdowns extends Walker_page {
function end_el(&$output, $item, $depth=0, $args=array()) {
if ($item -> ID == 55) { //checks if the page id is the list item I want to make my dropdown under
$vehicles = query_posts('post_type=vehicles'); //my custom post that I want to dropdown
if ($vehicles) { //check for no entries
//code for drop downs go here
}
}
}
}
this is in my theme.info file of my Drupal theme:
regions[conf_modules] = Configurator: modules
I'm using multiple templates for different node types. In one of them I'd like this region/block to show up. So I've put this in node--configurator.tpl.php:
<?php print render($page['conf_modules']); ?>
In the Drupal administration panel I have assigned a views block to the region, but on the node--configurator.tpl.php pages, the views block is not shown. Am I using render() properly? What's going wrong here? Thanks in advance!
In node templates, $page is simply a status variable that is:
True if the node is being displayed by itself as a page.
However, you can add regions to the page for specific content types through your page.tpl.php if you like. Something like below should work if placed in page.tpl.php:
<?php
if ($node->type == 'CONTENT_TYPE') {
print render($page['conf_modules']);
}
?>
I'm using the built-in Joomla! breadcrumb module, but nothing shows up but "Home" on all my pages.
I looked # the internals of the module, and inside /modules/mod_breadcrumbs/helper.php
$pathway = &$mainframe->getPathway();
$items = $pathway->getPathWay();
When I do a print_r on $items, the only thing in the array is "Home". My menus and sub-menus work fine, my urls show up as http://foobar.com/foo/bar
I failed to set a default menu, this caused all the problems.
I think you need to check your menu structure. I don't remember exactly how the breadcrumbs work, but it should run off the main menu. Do you need to make your menu items sub-menu items of "Home"?
EDIT: on second thoughts, I'm pretty sure it runs off the Section/Category listings. So you'd need to categorise all your articles.
This is joomla 1.5 breadcrumbs concept
$pathway =& $mainframe->getPathway();
$pathway->addItem( JText::_( 'Your Uploads' ),'index.php?option=com_useruploads');
$pathway->addItem('Edit Product');