Append some html text to a Yii Widget - php

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>}',

Related

Add styles to custom menu

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?

Jquery attr doesnt work on Yii

I'm trying to change the element value using Jquery but it's not working...
This is my widget where I have my element 'tag' which i want to change it to textField on edit...
$this->widget('EditableGrid', array(
'dataProvider' => $dataProvider->searchbyID($invoice_id),
'template' => '{items}{buttonCreateRow}{pager} ',
'id' => 'InvoiceLine-grid',
'rowTemplate' => $row_template,
'columns' => array(
array(
'class' => 'EditableGridColumn',
'header' => '',
'name' => 'InvoiceLine_{gridNum}_{rowNum}_edit',
'imageurl'=> Yii::app()->request->baseUrl.'/images/update.png',
'tag' => 'button',
'tagHtmlOptions' => array(
'onclick'=>'editline(this)',
)
),
array(
'class' => 'EditableGridColumn',
'header' => 'StentysRef',
'name' => '[{gridNum}][{rowNum}]stentysproductref',
'tag' => 'laabel',
'tagHtmlOptions' => array(
'style'=>'background-color:#FFF;border-color:#FFF',
'onkeyup'=>'stentysref(this)',
'readonly'=>true
)
),
My Jquery is,
(as you can see the removeAttr works but attr doesn't)
function editline(obj){
$("#InvoiceLine_1_"+row+"_stentysproductref").attr("tag","textField");
$("#InvoiceLine_1_"+row+"_stentysproductref").removeAttr("readonly");
}
Use .prop() and removeProp() which is added in jQuery 1.6, as the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior.
function editline(obj){
$("#InvoiceLine_1_"+row+"_stentysproductref").prop("tag","textField");
$("#InvoiceLine_1_"+row+"_stentysproductref").removeProp("readonly");
}
API Doc for .prop()
If you are using EditableGrid widget without pointing AR model, then the row id looks like
$('#_1_'+row+'stentysproductref').
I'll take it into consideration for the future updates. Thank you.

how do i change the alignment of yii framework pager?

<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $dataProvider,
'itemView' => '_view',
'ajaxUpdate' => true,
'pager' => array(
'class' => 'CLinkPager',
),
'template' => '{pager}{items}',
));
?>
after executing this the pager components are displaying as column format.is their any way to change that into row format?
I guess you getting this widget through renderPartial() method. When using the renderPartial() method controller not sending js and css files with response by default. If you want to get response with these files you should pass true in fourth parameter:
$this->renderPartial('myView',array(), false, true);

Yii Booster popover over text rather than button

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',
))?>

How to customize Yii CGridView Pager?

How to customize Yii CGridView Pager about its position, css, template?
You can custumize via 'pager' CGridView properties. Example:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'My-grid',
'dataProvider'=>$dataProvider,
'pager'=>array(
'header' => '',
'firstPageLabel' => '<<',
'prevPageLabel' => '<img src="images/pagination/left.png">',
'nextPageLabel' => '<img src="images/pagination/right.png">',
'lastPageLabel' => '>>',
),
'template'=>'{pager}{items}{pager}',
'columns'=>$arrayColumns,
));
http://www.yiiframework.com/doc/api/CBaseListView#pager-detail
http://www.yiiframework.com/doc/api/CBaseListView#pagerCssClass-detail
http://www.yiiframework.com/doc/api/CLinkPager
Here's another approach which worked for me.
Displaying Yii's CLinkPager "First" and "Last" Buttons
If you have troubles, make sure to read the comments below the entry.

Categories