I am working on framework yii ,I am using 2-column layout , all content from view are shown in the right column.
I want to show some widgets from view in the left column under menu. how can do it ?
Put in the widgets in the layout. Your view does not stand alone on a page, it usually stays in a layout. In the view (well not really but for the sake of the argument) I do
<?php
$this->breadcrumbs = array(
array('name' => 'Home', 'url' => array('/')),
array('name' => ($this->model->isNewRecord ? 'Create ' : 'Update ') . 'Contact',
);
?>
I can then do in the layout
<?php $this->widget('MyBreadCrumbs', array(
'crumbs' => $this->breadcrumbs,
)); ?>
Read more about the rendering process here: http://www.yiiframework.com/wiki/249/understanding-the-view-rendering-flow/
Related
I'm using Tabs widget in Yii2, and in the tabs of this widget I render 5 different views with Pagination using LinkPager, my problem is that when I click in the pagination of a Tab to go to the next page, it changes my tab to default one (The pagination changes and remains as a get parameter).
How can I stay in the same tab when moving to a different page in the same tab?
I've tried to add a parameter in Navigation that shows the active tab in the url, but pagination doesn´t work.
Here it is my navigation, I use the same format for all pagination, changing variable names for making it different:
$pagination = new Pagination([
'defaultPageSize' => 5,
'pageParam'=>'postPage',
'totalCount' => $sql->count(),
]);
Here it is my Tab widget ( I used 'active' for showing active tab as I said above, now for default shows as active first Tab)
<?php
echo Tabs::widget([
'items' => [
[
'label' => 'Actividad',
'content' => $this->render("#app/views/post/listado_posts", [
"pagination" => $paginationActividad,
"posts"=>$postsActividad,
]),
'active' => strcmp($activo, 'tabactividad')==0,
],
[
'label' => 'Posts',
'content' => $this->render("#app/views/post/listado_posts", [
"pagination" => $pagination,
"posts"=>$posts,
]),
'active' => strcmp($activo, 'tabpost')==0,
],
....
]);
?>
And finally, this is the LinkPager I use for each view:
<?= LinkPager::widget(['pagination' => $pagination]) ?>
I must have missed something. I can't figure out how to add some HTML into the title of the menu.
According to the menu api, I can't add options because I am using MENU_LOCAL_TASK, but then how? There is no say.
For example: if I try to make the title bold:
$items['whatever/tab2'] = array(
'title' => '<b>Tab 2</b>',
'type' => MENU_LOCAL_TASK,
);
This is not working.
You can use 'title callback' => 'example_title_callback',
Function to generate the title; defaults to t(). If you require only the raw string to be output, set this to FALSE.
You could use the Menu HTML module.
My main menu is appearing through print theme function but its sub menu is not appearing..What php code is written in template.php and then in page.tpl.php to get sub menus. I am trying for two days but no positive output.
If by sub-menu you mean a secondary menu on a particular page;
create the menu in structure >> menus >> Add Menu and add your links. Then go to structure >> blocks and find the block that corresponds to your menu and set it to appear on the relevant page and position within your theme.
If you want to add it within the .tpl file you can try something like this;
<nav class="header__secondary-menu" 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; ?>
I have a navigation and use it for breadcrumbs. I want to use it for top menu too , but I don't want to show my products in top menu.
How Can I achieve that ?
Add a custom attribute while defining the array in the module.config.php -
Eg:
array(
'label' => 'Product List',
'route' => 'product',
'action' => 'index',
'resource' => 'Product\Controller\Product:index',
'top_menu' => '0',
),
For the rest of the arrays set the top_menu attribute to 1.
In the partial file of top-menu, check -
<?php foreach ($this->container as $page) {
[...]
if($page->get('top_menu') == '1') {
//Code to display the menu.
}
[...]
} ?>
I hope it gives some idea.
I have a form with a textfield element which when a user starts typing into I want to pre-populate a different element.
I've been using the #ahah attribute which works fine with the event property set to 'keyup' however I lose focus on the textfield element because the moment the 'keyup' event is fired the whole form is rebuilt due to ahah's behaviour.
I tried setting the event property to 'change' and that works nicely however in order for the 'change' event to fire I need to click away from the textfield - so from UI point of view I cannot expect users to click away from field just to get the results to display.
I'm not sure if it's possible to achieve what I want with AHAH which is fine but I'd like to stick with it if possible.
Happy to provide code if required and sorry if it's not clear, quite difficult to explain.
Thanks
Steve
The whole form shouldn't be re-rendered by the browser. That's precisely the idea AHAH, that you can update just part of a form. Make sure to set the "wrapper" attribute (of the #ahah attribute) to the ID (as in: the HTML attribute) of the DOM element that you want Drupal's JS functionality to update asynchronously.
For example:
<?php
function MYMODULE_some_ahah_enabled_form(&$form_state) {
$initial_markup = '<div>' . t('This content will be replaced') . '</div>';
$form['dynamic_thing'] = array(
'#type' => 'markup',
'#prefix' => '<div id="dynamic-thing">', // Set Drupal's AHAH wrapper to this ID
'#suffix' => '</div>',
'#value' => $initial_markup,
);
$form['field_which_will_trigger_ahah_behavior'] = array(
'#type' => 'textfield',
'#ahah' => array(
'path' => 'MYMODULE/path/to/ahah/callback',
'wrapper' => 'dynamic-thing',
'event' => 'keyup',
),
'#default_value' => 'Change me',
);
return $form;
}
/**
* Your menu callback (which is declared in your hook_menu()) which returns only the HTML that will replace the existing markup in $form['dynamic_thing'].
*/
function MYMODULE_ahah_callback() {
$output = '<div>New content for the dynamic thing</div>';
drupal_json(array('status' => TRUE, 'data' => $output));
exit();
}
Your "field_which_will_trigger_ahah_behavior" DOM element in the browser shouldn't lose focus, or be re-rendered in any way, unless there's something else causing some bug.