bootstrap.widgets.TbDetailView, Yii app - yii

Model--
enter code here
public function searchShop()
{
$criteria = new CDbCriteria();
$criteria->compare("name", $this->category, TRUE, "OR");
$criteria->compare("shopname", $this->category, TRUE, "OR");
$criteria->compare("category", $this->category, TRUE, "OR");
return Shops::model()->findAll($criteria);
}
code----
enter code here
<?php
foreach($models as $model):
$this->widget(
'bootstrap.widgets.TbDetailView',
array(
'type'=>'bordered condensed',
'data' => array(
'id' =>array('view', 'id'=>$model->ID),
'Shop Name' => $model->shopname,
'Category' => $model->category,
'ID' => CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID))
),
'attributes' => array(
array('name' => 'Shop Name', 'label' => 'Shop name'),
array('name' => 'Category', 'label' => 'Category'),
array('name' => 'ID', 'label' => 'ID'),
),
)
);
echo "<br><hr><br>";
endforeach;
?>
I want a link on ID by clicking on it it will render view file i.e view.php of shops model
I used CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID)) but it is showing path of that view as 1
help me...
thanks in advance

try
CHtml::link(CHtml::encode($model->ID),
CController::createUrl('site/view',array('id'=>$model->ID)))
here i have assumed that action view lies in site controller. If it lies under some other module name then you can write like this "moduleName/controllerName/actionName"
Edit:
Ok you have to try a few things. TbDetailView extends CDetatilView. Now you can use TbDetailView as
$this->widget(
'bootstrap.widgets.TbDetailView',
array(
'type'=>'bordered condensed',
'data' => array(
'id' =>array('view', 'id'=>$model->ID),
'Shop Name' => $model->shopname,
'Category' => $model->category,
),
'attributes' => array(
array('name' => 'Shop Name', 'label' => 'Shop name'),
array('name' => 'Category', 'label' => 'Category'),
array('label' => 'ID', 'value' => CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID))),
),
)
);
You can also do like
$this->widget(
'bootstrap.widgets.TbDetailView',
array(
'type'=>'bordered condensed',
'data' =>$model,
'attributes' => array(
array('name' => 'shopname', 'label' => 'Shop name'),
array('name' => 'category', 'label' => 'Category'),
array('value' => CHtml::link(CHtml::encode($model->ID), array('view', 'id'=>$model->ID))
),, 'label' => 'ID'),
),
)
)
;

Related

hook with form Prestashop 1.7

guys (and ladies)
I like to ask you how to build the forms (formbuilder) in Prestashop 1.7 for the current 2020 year.
I created module with classes and hooks, but I can't find the info on how to create forms via "classes" and "controllers".
I'd happy to have something like this:
What have already done:
created custom module
created custom hook
custom .tpl from /module/templates/front/custom.tpl is added to the hook and displays data correctly.
Using form builder in your .php file (or controller)
return array(
'form' => array(
'legend' => array(
'title' => $this->l('Settings'),
'icon' => 'icon-cogs',
),
'input' => array(
array(
'type' => 'switch',
'label' => $this->l('Live mode'),
'name' => 'TESTONE_LIVE_MODE',
'is_bool' => true,
'desc' => $this->l('Use this module in live mode'),
'values' => array(
array(
'id' => 'active_on',
'value' => true,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => false,
'label' => $this->l('Disabled')
)
),
),
array(
'col' => 3,
'type' => 'text',
'prefix' => '<i class="icon icon-envelope"></i>',
'desc' => $this->l('Enter a valid email address'),
'name' => 'TESTONE_ACCOUNT_EMAIL',
'label' => $this->l('Email'),
),
array(
'type' => 'password',
'name' => 'TESTONE_ACCOUNT_PASSWORD',
'label' => $this->l('Password'),
),
),
'submit' => array(
'title' => $this->l('Save'),
),
),
);
}

Yii ESelect2 extension show preselected valued

i want to show already selected values in tags of ESelected extension but unable to find any solution my code in update form in view is
$this->widget('ext.select2.ESelect2', array(
'name' => 'cat_names[]',
'data' => Coupon::getCategories(),
'options' => array(
'placeholder' => '',
'allowClear' => true,
),
'htmlOptions' => array(
'multiple' => 'multiple',
),
));
if i add tags fields in option of Eselect it changes the behaviour and stop working i add tags in options like this
'tags' => Coupon::getCategories_old(),
Any suggestion will be helpfull thanks in advance
$this->widget('ext.select2.ESelect2', array(
'name' => 'cat_names[]',
'value'=> array(91,95),
'data' => Coupon::getCategories(),
'options' => array(
'placeholder' => '',
'allowClear' => true,
),
'htmlOptions' => array(
'multiple' => 'multiple',
),
));

Cannot do filtering via a dropdown menu in Yii TbGridView (v1.x.x)

I am trying to get the filtering to run although I am having some issues below is my view note that this in in a PARTIAL view :-
If I click on the header of the column it does the sorting as expected, however if I select an option from the dropdown it doesn't filter the items...
Any ideas?
<?php
$myuser = new Myuser('search');
$filterBtn = $this->widget('bootstrap.widgets.TbButton', array(
'icon' => 'filter',
'size' => 'small',
'label' => $myuser->paging ? 'View All' : 'View Less',
'htmlOptions' => array('class'=>'pull-right', 'style'=> 'margin:20px 0;'),
'url' => $myuser->paging ? array('/carrot/myuser/admin/paging/0') : array('/carrot/myuser/admin')
), true);
$this->widget('bootstrap.widgets.TbGridView',array(
'id' => 'myuser-grid','type'=>'striped bordered condensed',
'dataProvider' => $myuser->search(),
'filter' => $myuser,
'columns' => array(
array(
'id' => 'user_id',
'class' => 'CCheckBoxColumn',
'checked' => 'in_array($data->user_id, $this->grid->owner->model->student_ids)',
'checkBoxHtmlOptions' => array(
'name' => 'selected_student_id[]',
)
),
'firstname',
'surname',
'username',
array(
'name' => 'year_id',
'filter' => CHtml::activeDropDownList($myuser, 'year_id', CHtml::listData(Organisation::model()->distinctYears, 'year_id', 'year_id'), array('prompt'=>'All Years')),
'htmlOptions' => array('style' => 'text-align:center;'),
'headerHtmlOptions' => array('style' => 'text-align:left;'),
),
array(
'name' => 'form_name',
'header' => 'Form',
'filter' => CHtml::activeDropDownList($myuser, 'form_name', CHtml::listData(Organisation::model()->distinctForms, 'form_name', 'form_name'), array('prompt'=>'All Forms')),
),
array(
'name' => 'House',
'filter' => CHtml::activeDropDownList($myuser, 'House', CHtml::listData(Organisation::model()->distinctHouses, 'House', 'House'), array('prompt'=>'All Houses')),
),
),
)); ?>
My model has the following search() method:
public function search($limit = false)
{
$criteria = new CDbCriteria();
$criteria->compare('t.user_id',$this->user_id,true);
$criteria->compare('t.firstname',$this->firstname,true);
$criteria->compare('t.surname',$this->surname,true);
$criteria->compare('t.username',$this->username,true);
$criteria->compare('t.year_id',$this->year_id);
$criteria->compare('t.form_name',$this->form_name);
$criteria->compare('t.House',$this->House);
$criteria->compare('o.organisation_id',$this->organisation_id);
$criteria->group = 't.user_id';
$criteria->together = true;
return new CActiveDataProvider($this->currentUserOrganisation(), array(
'criteria' => $criteria,
'pagination' => array(
'pageSize' => $this->paging ? ($limit) ? $limit : OverviewController::PAGE_SIZE : 2000
),
'sort' => array(
'defaultOrder' => array('firstname'=>false, 'surname'=>false),
'attributes' => array(
'organisation_name' => array(
'asc' => 'organisation_name',
'desc' => 'organisation_name DESC',
'default' => 'desc',
),
'*'
)
),
));
}
I think you can't use a DropDownList as filter, but you can easily use CHTML::listData():
array(
'name' => 'year_id',
'filter' => CHtml::listData(Organisation::model()->distinctYears, 'year_id', 'year_id'),
'htmlOptions' => array('style' => 'text-align:center;'),
'headerHtmlOptions' => array('style' => 'text-align:left;'),
),
array(
'name' => 'form_name',
'header' => 'Form',
'filter' => CHtml::listData(Organisation::model()->distinctForms, 'form_name', 'form_name'),
),
array(
'name' => 'House',
'filter' => CHtml::listData(Organisation::model()->distinctHouses, 'House', 'House'),
),
This will automatically generate a DropDownList for you.
I hope this works for you.

YiiBooster Navbar target _blank

I am using the navbar of the extension Yiibooster, but I am having problems with a subitem of the menu, I need to go to a new tab, but I can't make it.
<?php $this->widget(
'bootstrap.widgets.TbNavbar',
array(
'brand' => '<img src ="' . Yii::app()->request->baseUrl . '/images/FAVICON.png" />Inicio',
'fixed' => false,
'collapse' => true,
'items' => array(
array(
'class' => 'bootstrap.widgets.TbMenu',
'items' => array(
array(
'label' => 'Informes',
'items' => array(
array('label' => 'Listado de Activos', 'url' => Yii::app()->baseUrl.'/ZfInmuebles/verpdf',
'itemOptions' => array('target' => '_blank')),
)),
If you want go to blank only in one item of the menu, this is the best option:
'items' => array(
array(
'label' => 'Informes',
'items' => array(
array(
'label' => 'Listado de Activos',
'url' => Yii::app()->baseUrl.'/ZfInmuebles/verpdf',
'linkOptions' => array(
'target' => '_blank'
),
),
),
),
)
Yii CMenu docs: http://www.yiiframework.com/doc/api/1.1/CMenu#items-detail
add class=>'bootstrap.widgets.TbMenu' like
'items' => array(
array(
'class' => 'bootstrap.widgets.TbMenu',
'submenuOptions' => array('target' => '_blank'),
'items' => array(
array('label' => 'Listado de Activos',
'url' => Yii::app()->baseUrl.'/ZfInmuebles/verpdf',
),
)
)
You need to use $brandOptions:
NavBar::begin([
'brandLabel' => 'Label text',
'brandUrl' => '/'.Yii::$app->homeUrl,
'brandOptions' => [
'target'=>'_blank'
],
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);

How to link to new blank page in tbbuttongroup yii

Given tbbuttongroup when user clicks the items I want to open a link to new blank page. I've tried the code below but it doesn't work.
<?php
$this->widget(
'bootstrap.widgets.TbButtonGroup',
array(
'type' => 'primary',
// '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons' => array(
array('label' => 'Action', 'url' => '#'),
array(
'items' => array(
array(
'label' => 'Cetak ke Pdf',
'url' => array("Tbpinjaman/cetakpdf",id=>$_GET[id]),
'target'=>'_blank',
),
array('label' => 'Export ke Excel', 'url' => 'Tbpinjaman/admin'),
)
),
),
)
);
<?php
$this->widget(
'bootstrap.widgets.TbButton', array(
'url'=> 'http://stackoverflow.com/',
'label'=>Yii::t('strings', 'stackoverflow'),
'htmlOptions' => array('target'=>'_blank')
));
?>
target on button widget must be put on htmloptions :
'htmlOptions' => array('target'=>'_blank')
Use linkOptions for your anchor items
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/cetakpdf/$_GET[id]','Your window name','width=500,height=700'); return false;"
)
Your code will come like this.
<?php
$this->widget('bootstrap.widgets.TbButtonGroup', array
(
'type' => 'primary',
'buttons' => array
(
array('label' => 'Action', 'url' => '#', 'htmlOptions' => array('id' => 'buttonStateful'),),
array
(
'items' => array
(
array
(
'label' => 'Cetak ke Pdf',
'url' => '#',
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/cetakpdf/$_GET[id]','Your window name','width=500,height=700'); return false;"
)
),
array
(
'label' => 'Export ke Excel',
'url' => '#',
'linkOptions' => array
(
'onclick' => "javascript:window.open('Tbpinjaman/admin','Your window name','width=500,height=700'); return false;"
)
)
)
)
)
));
?>
Try this :
<?php
$this->widget(
'bootstrap.widgets.TbButtonGroup',
array(
'type' => 'primary',
// '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
'buttons' => array(
array('label' => 'Action', 'url' => '#'),
array(
'items' => array(
array(
'label' => 'Cetak ke Pdf',
'url' => array("Tbpinjaman/cetakpdf",id=>$_GET[id]),
**'htmlOptions' => array('target'=>'_blank'),**
),
array('label' => 'Export ke Excel', 'url' => 'Tbpinjaman/admin'),
)
),
),
)
);