@media screen and (-webkit-min-device-pixel-ratio:0) {
/* put webkit CSS here*/
.search-form{
margin-top: 8px; margin-bottom: 5px; margin-left: -78px !important; margin-top: -73px; position: absolute;
}
// for Safari
::i-block-chrome, .eflat-menu li a {
padding-right:17px !important;
}
}
Wednesday, October 28, 2015
Css Hack for Safari Browser
Wednesday, October 14, 2015
Yii Delete Records With Multi Check Box
Yii::app()->clientScript->registerScript('deleteall','
$("#deleteall").click(function(){
var checked=$("#casecategory-grid").yiiGridView("getChecked","casecategory-grid_c0");
var count=checked.length;
if(count>0 && confirm("Do you want to delete these "+count+" item(s)"))
{
$.ajax({
data:{checked:checked},
url:"'.CHtml::normalizeUrl(array('Casecategory/removeall')).'",
success:function(data){$("#casecategory-grid").yiiGridView("update",{});},
});
}
});
');
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'casecategory-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'class'=>'CCheckBoxColumn', //CHECKBOX COLUMN ADDED.
'selectableRows'=>2, //MULTIPLE ROWS CAN BE SELECTED.
),
'name',
array(
'name'=>'parent',
'type'=>'raw',
'value'=>'$data->getparent ? $data->getparent->name : " No Parent"',
// 'filter' => CHtml::listData(User::model()->findAll(), 'id', 'fullname'),
),
array(
'class'=>'CButtonColumn',
),
),
));
echo CHtml::button("Remove Selected Items",array("id"=>"deleteall"));
// Controller
public function actionRemoveall()
{ if(Yii::app()->request->getIsAjaxRequest())
{
$checkedIDs=$_GET['checked'];
foreach($checkedIDs as $id)
Casecategory::model()->deleteByPk($id);
}
}
Wednesday, October 7, 2015
Create a widget on Yii
// protected/components/SubscriberFormWidget.php
class SubscriberFormWidget extends CWidget{
//put your code here
public $form;
public function run()
{
$model=new Subscribe;
// Uncomment the following line if AJAX validation is needed
if(isset($_POST['ajax']) && $_POST['ajax']==='subscribe-form')
{
echo CActiveForm::validate($model);
Yii::app()->end();
}
if(isset($_POST['Subscribe']))
{
$model->attributes=$_POST['Subscribe'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('subscriberFormWidget',array(
'modelsubs'=>$model,
));
// $this->render('subscriberFormWidget', array('modelsubs'=> new Subscribe()));
}
}
// protected/components/views/subscriberFormWidget.php
$form=$this->beginWidget('CActiveForm', array(
'id'=>'subscribe-form',
'action'=>Yii::app()->createUrl('subscribe/create'),
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true,
)
));
echo $form->error($modelsubs,'mobile_no');
echo $form->textField($modelsubs,'mobile_no',array('size'=>60,'maxlength'=>254,'class'=>'subscribe-now', 'placeholder'=>'Enter Your Mobile Number …'));
echo CHtml::submitButton($modelsubs->isNewRecord ? 'Subscribe Now' : 'Save',array('class'=>'btn btn-info btn-lg'));
$this->endWidget();
Inside any view
$this->widget('SubscriberFormWidget');
Wednesday, September 16, 2015
Yii EGMap color change
Add 'style' => '['.EGMap::MAPTYPECONTROL_STYLE_HORIZONTAL_BAR.', "map_style"]', in view page
$gMap = new EGMap();
$gMap->setWidth('auto');
$gMap->setHeight(500);
$gMap->zoom = 11;
$mapTypeControlOptions = array(
'position' => EGMapControlPosition::RIGHT_TOP,
'style' => '['.EGMap::MAPTYPECONTROL_STYLE_HORIZONTAL_BAR.', "map_style"]',
);
Replace this code in EGMap.php
public function registerMapScript($afterInit=array(), $language = null, $region = 'bd', $position = CClientScript::POS_LOAD)
{
// TODO: include support in the future
$params = 'sensor=false';
$params .= '&libraries=places';
if ($language !== null)
$params .= '&language=' . $language;
if ($region !== null)
$params .= '& region=' . $region;
CGoogleApi::init();
CGoogleApi::register('maps', '3', array('other_params' => $params));
$this->registerPlugins();
$js = '';
$init_events = array();
if (null !== $this->_appendTo)
{
$init_events[] = "$('{$this->getContainer()}').appendTo('{$this->_appendTo}');" . PHP_EOL;
}
// this for color change
$style_array_here="[
{ featureType: 'landscape',
elementType: 'all',
stylers: [ { hue: '#fad99d' }, { saturation: 87 }, { lightness: -10 }, { visibility: 'on' } ] },{ featureType: 'water', elementType: 'all', stylers: [ { hue: '#fad99d' }, { saturation: 82 }, { lightness: 16 }, { visibility: 'on' } ] } ];
var styledMap = new google.maps.StyledMapType(styles,
{name: 'Styled Map'})
";
$init_events[] = 'var styles = '.$this->encode($style_array_here).';' . PHP_EOL;
$init_events[] = 'var mapOptions = ' . $this->encode($this->options) . ';' . PHP_EOL;
$init_events[] = 'var '.$this->getJsName() . ' = new google.maps.Map(document.getElementById("' . $this->getContainerId() . '"), mapOptions); '.$this->getJsName().'.mapTypes.set("map_style", styledMap); '.$this->getJsName().'.setMapTypeId("map_style");' . PHP_EOL;
// add some more events
$init_events[] = $this->getEventsJs();
$init_events[] = $this->getMarkersJs();
$init_events[] = $this->getDirectionsJs();
$init_events[] = $this->getPluginsJs();
$init_events[] = $this->getPolygonsJs();
$init_events[] = $this->getCirclesJs();
$init_events[] = $this->getRectanglesJs();
if (is_array($afterInit))
{
foreach ($afterInit as $ainit)
$init_events[] = $ainit;
}
if ($this->getGlobalVariable($this->getJsName() . '_info_window'))
$init_events[] = $this->getJsName() . '_info_window=new google.maps.InfoWindow();';
if ($this->getGlobalVariable($this->getJsName() . '_info_box') && $this->resources->itemAt('infobox_config'))
$init_events[] = $this->getJsName (). '_info_box=new InfoBox('.
$this->resources->itemAt('infobox_config').');';
// declare the Google Map Javascript object as global
$this->addGlobalVariable($this->getJsName(), 'null');
$js = $this->getGlobalVariables();
Yii::app()->getClientScript()->registerScript('EGMap_' . $this->getJsName(), $js, CClientScript::POS_HEAD);
$js = 'function ' . $this->_containerId . '_init(){' . PHP_EOL;
foreach ($init_events as $init_event)
{
if ($init_event)
{
$js .= $init_event . PHP_EOL;
}
}
$js .= '
} google.maps.event.addDomListener(window, "load",' . PHP_EOL . $this->_containerId . '_init);' . PHP_EOL;
Yii::app()->getClientScript()->registerScript($this->_containerId . time(), $js, CClientScript::POS_END);
}
Tuesday, September 15, 2015
yii Select2 replacement for select boxes
Yii::import('ext.select2.Select2');
$data = CHtml::listData(Judge::model()->findAll(),'name', 'name');
echo Select2::multiSelect('judge', $model->judge, $data, array(
'required' => 'required',
'style' => 'width: 237px;',
'placeholder' => 'Judge Name',
'select2Options' => array('maximumSelectionSize' => 1,),
));
Wednesday, September 9, 2015
Add width, height and others attribute for image and link
echo CHtml::link(CHtml::image(Yii::app()->baseUrl."/uploads/promotion/".$promotion->image,$promotion->description,array('class'=>'promotion', 'title'=>$promotion->description)), "$promotion->url", array('target'=>'_self','class'=>'promotion'));
echo CHtml::image(Yii::app()->request->baseUrl.'/img/image.png',
'this is alt tag of image',
array('width'=>'100px','height'=>'100px','title'=>'image title here'));
Sunday, September 6, 2015
Limit Content Length in Yii
public function getPagesummary($id=null){
$model= Model::model()->findByPk($id);
$wordlimit= strip_tags($model->details);
if (str_word_count($wordlimit, 0) > 40) {
$words = str_word_count($wordlimit, 2);
$pos = array_keys($words);
$textt = substr($wordlimit, 0, $pos[40]) . '...';
return $textt;
}
else
return $wordlimit;
}
public function limitWords($id, $limit=50) {
$model= Model::model()->findByPk($id);
$text= strip_tags($model->details);
$word_arr = explode(" ", $text);
if (count($word_arr) > $limit) {
$words = implode(" ", array_slice($word_arr , 0, $limit) ) . ' ...';
return $words;
}
return $text;
}
$model->getPagesummary($model->id)
$model->limitWords($model->id)
Subscribe to:
Posts (Atom)