I can render my menu "Main Menu":
<?php if ($main_menu): ?>
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu-links',
'class' => array('nav', 'navbar-nav'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
<?php endif; ?>
All works fine!
Then i create custom menu "Custom Menu" with machine name: "custom-menu".
How can I render a this menu similar to the example above?
Thanks in advance.
Each Menu creates a block, and you can do templates for each blocks. Maybe that's an easier way to do it, see How to theme a menu block in Drupal?
Related
I Would like to use html codes in customizer API. But when I use it, WordPress removes the html tags.
In default area I used some html tags, But it does work on my actual page. Is there any way please ?
$wp_customize->add_setting('banner_title_display',array(
'default' => 'Largest <span> GiveAway</span> collections <small>Online</small>',
'sanitize_callback' => array($this, 'sanitize_custom_options')
));
$wp_customize->add_control(new WP_Customize_Control($wp_customize,'banner_title_display_control',array(
'label' => 'Main header text',
'section' => 'baner_header_section',
'settings' => 'banner_title_display',
'type' => 'textarea'
)));
So I have the following code:
add_action('customize_register', 'homepage_sections');
//products
function homepage_sections($wp_customize){
$wp_customize->add_panel('homepage_sections', array(
'title' => 'Homepage Sections',
'priority' => '20'
));
$wp_customize->add_section('homepage_settings_section', array(
'title' => 'Homepage settings',
'panel' => 'homepage_sections',
));
$wp_customize->add_setting('homepage_settings_setting', array(
'default' => 1
));
$wp_customize->add_control('homepage_settings_control', array(
'section' => 'homepage_settings_section',
'settings' => 'homepage_settings_setting',
'label' => 'Number of sections',
'description' => 'Number of sections in homepage',
'type' => 'number'
));
global $wpdb;
$sections=$wpdb->get_results('SELECT section_id, section_title FROM vt_homepage_sections;');
foreach($sections as $key){
$section_id=$key->section_id;
$cust_setting_id=$section_id.'_setting';
$cust_control_id=$section_id.'_control';
$wp_customize->add_setting($cust_setting_id,array(
));
$wp_customize->add_control($cust_control_id,array(
'settings' => $cust_setting_id,
'section' => 'homepage_settings_section',
'label' => 'test Control'
));
}
}
Issue
Everything works fine when i don't use variables which contain a value fetched using $wpdb. Is $wpdb object loaded after customizer framework?
When I use the code above, the above customized objects font appear in the customizer panel. Would appreciate hints to what's wrong with my code above.
Thanks in advance,
J
Please try this like this '$sections = $wpdb->get_results('SELECT section_id, section_title FROM vt_homepage_sections');'
define global class at the start of function and check.
I have the following Yii widget and want to pass some html at the just before and just after the items are iterated through- can anyone explain how I do this?
$this->widget('application.widgets.zii.ListViewShowAll', array(
'summaryText' => false,
'template' => '{items}',
'htmlOptions' => array(),
'itemView' => 'application.views.widgets.account.prizes._mainprizeItem',
);
Just amended the widget code above...
'template' => '{<p>someting</p> items <p>more text</p>}',
what is the use of links__system_main_menu in drupal?
<?php if ($main_menu): ?>
<div id="main-menu" class="navigation">
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu-links',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
</div> <!-- /#main-menu -->
This is a pattern for theme hook, in the form [base hook]__[context]. When links theme with theme('links__system_main_menu', $variables), theme() function search for *theme_links__system_main_menu()* and use it. Otherwise, if it doesn't find, it will use *theme_links()*. For more information check the theme Doc
Yii booster documentation shows how to make a popover over a button. I want to create one over an anchor element rather than a button. Essentially I want to combine the popover with Yii's tooltip. Does anyone know how to do this?
This is the code for the pop-over:
$this->widget(
'bootstrap.widgets.TbButton',
array(
'label' => 'Top popover',
'type' => 'primary',
'htmlOptions' => array(
'data-title' => 'A Title',
'data-placement' => 'top',
'data-content' => "And here's some amazing content. It's very engaging. right?",
'data-toggle' => 'popover'
),
));
If there was a way of altering this to not render a button, but just an anchor the problem would be solved, but I can't find anything in the code that I can use to do this.
Update
Following Sergey's answer, here's what I've put:
echo CHtml::Link("$detail->text", null,
array(
'rel' => 'popover',
'data-trigger' => "hover",
'data-title' => "$header",
'data-content' => "$body"
));
This is close to what I need, but for some reason the hove doesn't work, only the click and also only the content get's displayed not the title.
You can use CHtml:
<?php echo CHtml::Link('<i class="icon-info-sign"></i>', null, [
'rel' => 'popover',
'data-trigger' => 'hover',
'data-title' => 'Your title',
'data-content' => 'Your content',
])?>
Update:
For Bootstrap 2.3.2 :
<?php Yii::app()->clientScript->registerScript("", "$('.ipopover').popover();", CClientScript::POS_READY) ?>
<?php echo CHtml::Link('<i class="icon-info-sign"></i>', null, array(
'class' => 'ipopover',
'data-trigger' => 'hover',
'data-title' => 'Your title',
'data-content' => 'Your content',
))?>