user-menu in secondary-menu: why? - drupal

I've created a sub of the zen-theme. And am mighty proud of it, but up in the top right corner (#secondary-menu) the user-menu shows up - perfectly.
I just don't understand how it get's there?
In structure/blocks the user-menu appears in the Disabled section (Region: None)
In fact, there IS no region called "secondary-menu" (id of the element gotten from Firebug)
Isn't that strange?

I can't comment on your specific template files but the standard Zen page.tpl.php file has this in it:
<?php if ($secondary_menu): ?>
<nav id="secondary-menu" role="navigation">
<?php print theme('links__system_secondary_menu', array(
'links' => $secondary_menu,
'attributes' => array(
'class' => array('links', 'inline', 'clearfix'),
),
'heading' => array(
'text' => $secondary_menu_heading,
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
</nav>
<?php endif; ?>
Which should answer how the menu gets printed to the page. If you want to dig one step deeper, the $secondary_menu variable is set up in template_preprocess_page().
As to why it's the user menu...if you go to admin/structure/menu/settings you should see this:
If you change the secondary link source to something else you should see that reflected in your theme too.

Related

Wordpress custom theme - menu not showing when called in footer.php

I'm trying to create custom website theme for Wordpress and I ran into a bit of a problem. I use two absolutely same menus in my header and footer part of website.
Calling
wp_nav_menu(array('theme_location' => 'header'));
in header.php works well, the menu prints out without any problem, but if I do the same in my footer.php file, the menu doesn't print and var_dump(wp_nav_menu(array('theme_location' => 'header'))); prints false.
I've tried some workarounds that I found on Google with modifying the functions.php file, but none of them helped me resolve that problem. My functions.php file now consists of only one line
register_nav_menus( array( 'header' => 'Header menu', 'footer' => 'Footer menu' ) );
and yes, I tried to use
wp_nav_menu(array('theme_location' => 'footer'))
as well, with same result. If I call the same function from header.php
wp_nav_menu(array('theme_location' => 'footer'))
the menu works good.
You have registered you two nav menus correctly. I always do that within my initial theme setup hook that gets hooked to the after_setup_theme hook. So I would do something like this in your functions.php:
function pietergoosen_theme_setup() {
register_nav_menus( array(
'header' => 'Header menu',
'footer' => 'Footer menu'
) );
}
add_action( 'after_setup_theme', 'pietergoosen_theme_setup' );
Keep in mind, you don't have to do it this way. The following also works
register_nav_menus( array(
'header' => 'Header menu',
'footer' => 'Footer menu'
) );
You should now see the two menus in the backend under "Appearance > Menus > Manage Locations" (Only if a menu exist)
For the sake of the footer menu, add the following code in your footer where you need to display the menu:
<nav id="footer-navigation" class="site-navigation footer-navigation" role="navigation">
<?php wp_nav_menu( array( 'theme_location' => 'footer', 'menu_class' => 'nav-menu', 'fallback_cb' => false ) ); ?>
</nav>
At this stage nothing will be displayed, and I think this is where you also get stuck at. The reason for this is that there aren't any items assigned to the menu, and if there are nothing assigned to a menu, then nothing will be displayed. So we have to insert something to be displayed.
In the backend, go to "Appearance > Menus > Edit Menus". In the "Menu Name" field, enter a name for your menu and click "Create Menu". You will now be able to add the menu in the menu screen.
You can now choose items from the left hand side to insert into your menu. You can also set the location of the menu, in this case in the footer. I've selected to display the categories in the footer. Click "Save Menu" when done.
You should now see your nav menu in the front end.
You just have to add styling to your nav bar now. You will do exactly the same for the header nav menu, accept you will add the call to the menu in the header.php. I hope you find this usefull.
So I’m producing my second WP theme and I’ve struck a problem. As well as the standard Nav menu at the top of my pages, the Footer element contains three individual sub-menus that can be loaded with individual entries. These are broken into three areas: Product Range, Industry Type and Services. The source code on footer.php is thus:
<div class="col-sm-3" style="float:left">
<h3>Product Range</h3>
<?php wp_nav_menu( array( 'footer' => 'product-range', 'container_class' => 'footer-menu' ) ); ?>
</div>
<div class="col-sm-3" style="float:left">
<h3>Industry Type</h3>
<?php wp_nav_menu( array( 'footer' => 'industry-type', 'container_class' => 'footer-menu' ) ); ?>
</div>
<div class="col-sm-3" style="float:left">
<h3>Services</h3>
<?php wp_nav_menu( array( 'footer' => 'services', 'container_class' => 'footer-menu' ) ); ?>
</div>
In functions.php I have included:
*Add footer Menus
*/
function register_my_menus() {
register_nav_menus(
array(
'product-range' => __( 'Product Range' ),
'industry-types' => __( 'Industry Types' ),
'services' => __( 'Services' )
)
);
}
add_action( 'init', 'register_my_menus' );
The output to all three menus is identical, and it is not what I want:
Product Range
COVID19 Policy
Latest and Greatest
About Us
Contact us1
Customer Service
Our Guarantee
Industry Type
COVID19 Policy
Latest and Greatest
About Us
Contact us1
Customer Service
Our Guarantee
Services
COVID19 Policy
Latest and Greatest
About Us
Contact us1
Customer Service
Our Guarantee
The top two items I added in the CMS, the remainder are automatically generated form somewhere else?
What gives?

Drupal: Sub menu of main menu not showing in zen subtheme

Failed to list out sub menu items using zen subtheme.
My main menu:
-> Home
-> Product
-> men
-> female
-> about
MY PROBLEM:
-> sub menu "men" and "female" are not shown
WHAT I HAVE DONE SO FAR:
My code in page.tpl.php
<?php if ($main_menu): ?>
<?php
// This code snippet is hard to modify. We recommend turning off the
// "Main menu" on your sub-theme's settings form, deleting this PHP
// code block, and, instead, using the "Menu block" module.
// #see https://drupal.org/project/menu_block
print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'class' => array('links', 'inline', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
<?php endif; ?>
<?php print render($page['navigation']); ?>
I have checked "Show as expanded" for product menu item in main menu also.
Please provide me solution.

Is it possible to give condition to check directory and based on that give the code?

I'll try to be as clear as I can because it's pretty difficult to write it down...
Situation: Problem occured when working with WordPress. I have WPML (multilingual site) plugin installed and it works perfectly but the problem is that I am using this theme which has custom posts such as Homepage Text and Homepage Boxes and those two posts that appear on my homepage do not have a possibility of translating content into other languages to have that Homepage Text and Boxes in different languages (that part of the WPML plugin just doesn't appear there). Homepage Text and Homepage Boxes, those two appear on the left side of wordpress - it's a part of menu, just like Links, Pages or Comments...
I kind of came up with one way of solving this.
I created a few more of these custom posts. Now I have:
Homepage Text (home_text)
Homepage Boxes (home_boxes)
Homepage Text English (home_text_en)
Homepage Boxes English (home_boxes_en)
Homepage Text Russian (home_text_ru)
Homepage Boxes Russian (home_boxes_ru)
There are two pieces of code in index.php for these two custom posts. I'll show you one:
<div id="homepage-text">
<?php query_posts(array(
'post_type'=>'home_text',
'orderby' => 'ASC'
));
?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post();?>
<h2><?php the_title() ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
</div><!-- /homepage-text -->
After this, there's a similar code for Homepage Boxes...
Way of solving: Writing a code which says: "if the address you are coming from says http://www.website.eu - use homepage text and boxes that are home_text and home_boxes; If it's http://www.website.com/EN - use home_text_en, and so on... I hope you get what I'm saying..
Is here anyone who had enough time to read all of this and would be so kind and write me that piece of code that translates my words into php?
That's my guess of how should that look but I'm stugling with writing conditions.
if (condition that it's the main language directory)
{
register_post_type( 'home_text',
array(
'labels' => array(
'name' => __( 'Homepage Text' ),
'singular_name' => __( 'Homepage Text' )
),
'public' => true,
'supports' => array('title','editor')
)
);
}
elseif (condition that it's english language directory .com/en)
{
register_post_type( 'home_text_en',
array(
'labels' => array(
'name' => __( 'Homepage Text English' ),
'singular_name' => __( 'Homepage Text English' )
),
'public' => true,
'supports' => array('title','editor')
)
);
}
else
{
register_post_type( 'home_text_ru',
array(
'labels' => array(
'name' => __( 'Homepage Text Russian' ),
'singular_name' => __( 'Homepage Text Russian' )
),
'public' => true,
'supports' => array('title','editor')
)
);
}
Thank's in advance.
Domantas.
You can use the Page Referer function of WordPress http://codex.wordpress.org/Function_Reference/wp_get_referer to do something like:
$page_referer_url = wp_get_referer();
if(strpos($page_referer_url,'.com/en')!==FALSE) { // Check if the text '.com/en' is part of the referer URL
// code for english
}
else {
// code for non english
}
You can find how strpos() works here http://php.net/manual/en/function.strpos.php

wrong wp_nav_menu displayed

my url looks like this:
http://domain.com/?s=searchquery&post_type=qa_faqs
that page lists search results for "searchquery".
i then get the post type with
$post_type = $_GET['post_type'];
it echoes correctly
echo $post_type;
// Provides: qa_faqs
i then do an if/else to display a different menu via wp_nav_menu when $post_type is qa_faqs.
if ( $post_type == 'qa_faqs' ) {
echo 'we got qa_faqs over here';
wp_nav_menu(array('menu' => 'meta_menu', 'items_wrap' => '<dl id="%1$s" class="nice tabs vertical %2$s">%3$s</dl>', 'walker' => new sidenav_walker ));
} else {
echo 'no qa_faqs in da house';
wp_nav_menu(array('menu' => 'service_menu', 'items_wrap' => '<dl id="%1$s" class="nice tabs vertical %2$s">%3$s</dl>', 'walker' => new sidenav_walker ));
}
now to the funny part:
even though the page echoes 'we got qa_faqs over here', it displays the service_menu.
why´s that?
Found it - http://codex.wordpress.org/Navigation_Menus
Same problem was driving me nuts aswell.
Use 'theme_location' instead of 'menu' to point to which menu you want to output.
Try targetting the specific menu with something like:
<?php wp_nav_menu( array('menu' => 'Your Menu Name' )); ?>
I think you dont have any items on the meta_menu. Please create menu under Appearance section and assign it. :)

Yii button with property submit - is not working

Yesterday it was working. After many changes (but not with it template) - it's not.
Yii generates button as usually, but now by clicking it does nothing.
<?= CHtml::button('Sell', array(
'submit' => CController::createUrl('product/selll', array('productID' => $data->id)),
'style' => 'width:80px',
)); ?>
Maybe i have found the problem - it is because jquery.yiiactiveform.js is not loading automaticly. Why it's not loading any more?
I have found solution. The problem is Yii form above, i've comment input text field, than no one Yii::button is working at all.
This is a code of form above:
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'searform',
'enableClientValidation' => true,
'enableAjaxValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),
'action' => array("user/searchForm"),
));?>
!!!!If i comment this textField - no one CHtml::button dont work.!!!!!
<?php echo $form->textField($search,
'product',array('width'=>'179px','height'=>'17px','value'=>$value,'save'=>$value)); ?>
<? /*
<div id="srcBtnWrap">
<?= CHtml::submitButton('',array('id'=>'srcBtn')); ?>
</div> */ ?>
<? //= CHtml::submitButton('go'); ?>
<?
$this->endWidget();
?>
Is it Yii bug, or i do something wrong?
jquery.yii.js should be loaded. If it is loaded - check JS console for errors.
Check if your action does not use die() or exit()
You have enabled client validation. Please, check errors and give us model fields (rules)
'enableClientValidation' => true,
'enableAjaxValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
),

Resources