I have a weird problem. I copied my website into production environment (from windows to ubuntu). I correct few big/small letter issues and app started to work fine. Until I entered one page that looks like it's being rendered without layout. There is no error.
Also - firebug shows no css styles or anything. At HTML source there is lack of layout code too.
What could be the reason of that?
EDIT:
controller part:
$dataProvider = Projects::model()->getInviteProjectsProvider();
$this->render('invite', array(
'dataProvider' => $dataProvider
));
It returns CActiveDataProvider.
View:
<?php
$this->breadcrumbs=array(
'Projekty' => array('admin'),
'Zapraszanie',
);
$this->renderPartial('_allMenu');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->module->assetsUrl; ?>/css/projects.css"/>
<h1>Projekty aktywne - zapraszanie</h1>
<?php
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'id' => 'invite-grid',
'type' => 'striped condensed',
'dataProvider' => $dataProvider,
'rowCssClassExpression' => '($data->leftCustomers<100) ? "error":""',
'columns' => array(
array(
'name' => 'idProject',
'htmlOptions' => array('width' => '60px', 'style' => 'text-align: right;', 'class' => 'gridIdColumn'),
),
'name',
array(
'name' => 'leftCustomers',
'header' => 'Pozostało <i class="icon-info-sign" rel="tooltipbootstrap" data-original-title="Gdy wartość ta jest mniejsza niż 100 - rekord jest podświetlony na czerwono"/>',
),
'confirmStart',
'presentationDate',
array(
'class' => 'bootstrap.widgets.TbRelationalColumn',
'name' => 'Statystyki',
'value' => '"Pokaż"',
'url' => $this->createUrl('dynamicProjectStats')
),
array(
'header' => 'Postęp <i class="icon-info-sign" rel="tooltipbootstrap" data-original-title="Liczba zaproszeń / Limit zaproszeń"/>',
'value' => function($data)
{
$prc = round(($data->projectMaxInvites > 0) ? ($data->projectInvites)/ $data->projectMaxInvites * 100 : 0, 2);
Controller::widget('bootstrap.widgets.TbProgress', array(
'percent' => $prc,
'htmlOptions' => array(
'style' => 'height: 20px; margin-bottom: -20px',
'rel' => 'tooltipbootstrap',
'data-original-title' => $prc." %",
),
));
},
),
array(
'class' => 'bootstrap.widgets.TbButtonColumn',
'template' => '{view}{update}{delete}',
'htmlOptions' => array(
'style' => 'width: 40px;',
),
),
array(
'header' => '',
'htmlOptions' => array('style' => 'width: 43px'),
'value' => function($data)
{
$this->renderPartial('partials/_actionMenu', array('idProject' => $data->idProject, 'activated' => true, 'afterAction' => 'removeActiveProject'));
}
),
array(
'header' => '',
'value' => function($data)
{
$this->renderPartial('partials/_statMenu', array('idProject' => $data->idProject, 'showIcon' => true));
}
),
)
));
?>
I noticed that if I comment out the columns where function($data) is used - it shows fine. When I leave it - there is no layout displayed.
EDIT2:
Maybe I should notice the fact that inside partials/_statMenu and partials/_actionMenu there is a bootstrap.widgets.TbButtonGroup widget rendered.
Try:
Yii::app()->controller->renderPartial(...)
Instead of:
$this->renderPartial(...)
Related
I have a custom admin page in prestashop and i would like to add a URL link at the bottom of that page. However, i am very new to prestashop and can not figure out how to do this.
I have an admin controller file for the module that creates the custom page with a form on it and was wondering how i can add a link at the bottom of the page that simply goes to another static page on the site or even an external page.
AdminFedeltaSchoolsController.php content
<?php
class AdminFedeltaSchoolsController extends ModuleAdminController {
public function __construct() {
// Configure admin controller with table, model, language and bootstrap theme
$this->table = 'fedeltapos_school';
$this->className = 'FedeltaposModel';
$this->lang = true;
$this->bootstrap = true;
// Generat action on list
$this->addRowAction('edit');
$this->addRowAction('delete');
// This adds a multiple deletion button
$this->bulk_actions = array(
'delete' => array(
'text' => $this->l('Delete selected'),
'confirm' => $this->l('Delete selected items?')
)
);
// Generat list
$this->fields_list = array(
'id_fedeltapos_school' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 25
),
'school_name' => array(
'title' => $this->l('School Name'),
'width' => 'auto'
),
'delivery' => array(
'title' => $this->l('Delivery'),
'width' => 'auto'
),
'pickup' => array(
'title' => $this->l('Pickup'),
'width' => 'auto'
),
'pricelevel' => array(
'title' => $this->l('Price Level'),
'width' => 'auto',
),
);
parent::__construct();
}
// This method generates the Add/Edit form
public function renderForm() {
// Building the Add/Edit form
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Schools'),
'icon' => 'icon-envelope-alt'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('School Name:'),
'name' => 'school_name',
'lang' => true,
'size' => 33,
'required' => true,
), array(
'type' => 'text',
'label' => $this->l('Delivery:'),
'name' => 'delivery',
'size' => 33,
'required' => true,
),
array(
'type' => 'text',
'label' => $this->l('Pickup:'),
'name' => 'pickup',
'size' => 33,
'required' => true,
),
array(
'type' => 'text',
'label' => $this->l('Price Level:'),
'name' => 'pricelevel',
'size' => 33,
'required' => true,
),
),
'submit' => array(
'title' => $this->l('Save')
)
);
return parent::renderForm();
}
}
I would like the link at the bottom of the page (see screenshot):
http://awesomescreenshot.com/08252wdh8a
Any assistance will be appreciated.
Override the default content admin template file of your admin controller.
Create /your-admin-folder/themes/default/template/controllers/fedelta_schools/content.tpl
{if isset($content)}
{$content}
{/if}
{block name="override_tpl_schools"}
<div class="row">
<div class="col-lg-12">
<div class="panel">
<h3>
<i class="icon-info"></i>
{l s='Help'}
</h3>
<p>{l s='You can find answer of your question here :'} <a href='#'>{l s='FAQ'}</a> </p>
</div>
</div>
</div>
{/block}
I am having trouble submitting/saving data to the CakePHP Model. I constructed the form as usual as I always do, but this time I am getting notices and warning an also data is not getting saved. Here is the form I have constructed and method in Controller:
educationaldetails.ctp
<?php
if (empty($Education)):
echo $this->Form->create('Candidate', array('class' => 'dynamic_field_form'));
echo $this->Form->input('CandidatesEducation.0.candidate_id', array(
'type' => 'hidden',
'value' => $userId
));
echo $this->Form->input('CandidatesEducation.0.grade_level', array(
'options' => array(
'Basic' => 'Basic',
'Masters' => 'Masters',
'Doctorate' => 'Doctorate',
'Certificate' => 'Certificate'
)
));
echo $this->Form->input('CandidatesEducation.0.course');
echo $this->Form->input('CandidatesEducation.0.specialization');
echo $this->Form->input('CandidatesEducation.0.university');
echo $this->Form->input('CandidatesEducation.0.year_started', array(
'type' => 'year'
));
echo $this->Form->input('CandidatesEducation.0.year_completed', array(
'type' => 'year'
));
echo $this->Form->input('CandidatesEducation.0.type', array(
'options' => array(
'Full' => 'Full',
'Part-Time' => 'Part-Time',
'Correspondence' => 'Correspondence'
)));
echo $this->Form->input('CandidatesEducation.0.created_on', array(
'type' => 'hidden',
'value' => date('Y-m-d H:i:s')
));
echo $this->Form->input('CandidatesEducation.0.created_ip', array(
'type' => 'hidden',
'value' => $clientIp
));
echo $this->Form->button('Submit', array('type' => 'submit', 'class' => 'submit_button'));
echo $this->Form->end();
endif;
CandidatesController.php
public function educationaldetails() {
$this->layout = 'front_common';
$this->loadModel('CandidatesEducation');
$Education = $this->CandidatesEducation->find('first', array(
'conditions' => array(
'candidate_id = ' => $this->Auth->user('id')
)
));
$this->set('Education', $Education);
// Checking if in case the Candidates Education is available then polpulate the form
if (!empty($Education)):
// If Form is empty then populating the form with respective data.
if (empty($this->request->data)):
$this->request->data = $Education;
endif;
endif;
if ($this->request->is(array('post', 'put')) && !empty($this->request->data)):
$this->Candidate->id = $this->Auth->user('id');
if ($this->Candidate->saveAssociated($this->request->data)):
$this->Session->setFlash('You educational details has been successfully updated', array(
'class' => 'success'
));
return $this->redirect(array(
'controller' => 'candidates',
'action' => 'jbseeker_myprofile',
$this->Auth->user('id')
));
else:
$this->Session->setFlash('You personal details has not been '
. 'updated successfully, please try again later!!', array(
'class' => 'failure'
));
endif;
endif;
}
Here is the screenshot of errors I am getting, Not able to figure out what is happening while other forms are working correctly. looks like something something wrong with view?
This error is coming out because you are not passing the proper arguments to the session->setFlash() method, you are doing like this:
$this->Session->setFlash('You personal details has not been updated successfully, please try again later!!', array(
'class' => 'failure'
));
In docs it is mentioned like:
$this->Session->setFlash('You personal details has not been updated successfully, please try again later!!',
'default', array(
'class' => 'failure'
));
Hi so if i understand :
array(
'CandidatesEducation' => array(
(int) 0 => array(
'candidate_id' => '5',
'grade_level' => 'Basic',
'course' => 'Masters of Computer Application',
'specialization' => '',
'university' => 'Mumbai University',
'year_started' => array(
'year' => '2011'
),
'year_completed' => array(
'year' => '2014'
),
'type' => 'Full',
'created_on' => '2014-11-27 15:44:36',
'created_ip' => '127.0.0.1'
)
)
),
Is your data , and you just need to save this in your candidates_educations table , so in this case i would do :
$this->Candidate->CandidatesEducation->save($this->request->data);
and your $data had to look :
array(
'CandidatesEducation' => array(
'candidate_id' => '5',
'grade_level' => 'Basic',
'course' => 'Masters of Computer Application',
'specialization' => '',
'university' => 'Mumbai University',
'year_started' => array(
'year' => '2011'
),
'year_completed' => array(
'year' => '2014'
),
'type' => 'Full',
'created_on' => '2014-11-27 15:44:36',
'created_ip' => '127.0.0.1'
)
);
the saveAssociated is used when you create your Model AND Model associated , not only your Associated model.
And : i m not sure for year_started and year completed rm of data, it depends of your table schema ; what's the type of year_completed and year_started ?
Yii infinite scroll extention: "IasPager pager" not working after ajax update on clistveiw.
It's working fine before ajax call but after ajax call when i update listview it's not working.
$this->widget('zii.widgets.CListView', array(
'id' => 'VideoList',
'dataProvider' => $dataProvider,
'itemView' => '_view',
'template' => '{items} {pager}',
'pager' => array(
'class' => 'ext.infiniteScroll.IasPager',
'rowSelector'=>'.row',
'listViewId' => 'VideoList',
'header' => '',
'loaderText'=>'Loading...',
'options' => array('history' => false, 'triggerPageTreshold' => 2, 'trigger'=>'Load more'),
)
)
);
I have found solution of this, it works fine.
<?php
$this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'/products/viewProductList',
'summaryText'=>false,
'emptyText'=>"<p> Coming Soon!!</p>",
'id'=>'ajaxProductListView',
'cssFile'=>Yii::app()->baseUrl.'/css/mycustom.css',
'template' => '{items} {pager}',
'ajaxUpdate'=>true,
'pager' => array(
'class' => 'ext.infiniteScroll.IasPager',
'rowSelector'=>'.ademo',
'listViewId' => 'ajaxProductListView',
'header' => '',
'loaderText'=>'Loading',
'options' => array('history' => false, 'triggerPageTreshold' => 1, 'trigger'=>'Load more'),
),
'afterAjaxUpdate'=>"function(id, data) {
$.ias({
'history': false,
'triggerPageTreshold': 1,
'trigger': 'Load more',
'container': '#ajaxProductListView',
'item': '.ademo',
'pagination': '#ajaxProductListView .pager',
'next': '#ajaxProductListView .next:not(.disabled):not(.hidden) a',
'loader': 'Loading...'
});
}",
));?>
there are 2 columns check box in cgridViewtable and two bootstrap widgets TbButton in view page.
I can not get value of my checkbox very good. My value in checkboxs transfer into controller but changed id of checkboxs After a period of timeand , and controller don't knew checkbox,
View:
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'id' => 'profile-information-form',
'enableAjaxValidation' => false,
));
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => Yii::t('fa_ir', 'First validation'),));
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => Yii::t('fa_ir', 'End validation'),));
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'profile-information-grid',
'dataProvider' => $model->children(),
'filter' => $model,
'columns' => array(
array(
'header' => '',
'value' => '$this->grid->dataProvider->pagination->offset + $row+1', // row is zero based
),
array(
'name' => 'ProfileInformation.user.scope',
'value' => 'CHtml::encode($data->user->scope->name)',
'filter' => Scope::model()->options,
),
array(
'name' => 'id',
'value' => 'CHtml::encode($data->id)',
),
array(
'name' => 'center',
'value' => 'CHtml::encode($data->center)',
),
array(
'name' => 'sendCount',
'value' => 'CHtml::encode($data->sendCount)',
'filter' => '',
),
// Use CCheckbox column with selectableRows = 2 for Select All
array('class' => 'CCheckBoxColumn', 'selectableRows' => 2, 'visible' => (Lookup::isUser2(Yii::app()->user->id) or Lookup::isAdmin(Yii::app()->user->id))),
array('class' => 'CCheckBoxColumn', 'selectableRows' => 2, 'visible' => (Lookup::isUser1(Yii::app()->user->id) or Lookup::isAdmin(Yii::app()->user->id))),
),
));
// action button
$this->endWidget();
Controller:
if (isset($_POST['profile-information-grid_c10']) & isset($_POST['yt0'])) {
////Do action1
}
if (isset($_POST['profile-information-grid_c12']) & isset($_POST['yt1'])) {
////Do action2
}
}
my problem is in $_POST['profile-information-grid_c10'] and _POST['profile-information-grid_c12'] , before id were $_POST['profile-information-grid_c8'] and $_POST['profile-information-grid_c10'] , and now is $_POST['profile-information-grid_c12'] and $_POST['profile-information-grid_c14'].
my problem is very involved. I cannot explain very good.
I want to have a fix id.
I donto why change id of check box?
Can I assign ids for checkboxs?
Can I assign ids for checkboxs? Sure, you better explicitly set checkbox column id:
'class' => 'CCheckBoxColumn', 'id'=>'column1', ... see these docs.
This way you firmly set it and you'll have no things like these yt0, yt2...
The same you can do for the buttons. See TButton docs.
Also you need to use double && in logical condition:
isset($_POST['profile-information-grid_c12']) & isset($_POST['yt1'])
i'm facing an issue with the filter input box in CGridView. So the filter is showing the correct result after entering the search string in the filter input box and hitting enter, but the input box is getting cleared after the result is being shown. This makes it quite inconvenient for the user to see what they was searching for because the filter input box is empty while the grid shows the correct search results.
Here are the code.
entry view name ::newsReleases.php
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'product-news-grid-' . $id,
'itemsCssClass' => 'table table-striped',
'htmlOptions' => array(
'class' => 'news-datagrid',
),
'dataProvider' => $dataProvider->searchProductNews($symbol),
'filter' => $dataProvider,
'enableHistory' => false,
'ajaxUpdate' => 'product-news-grid-' . $id,
'ajaxUrl' => Yii::app()->createUrl('/realTime/AjaxUpdateProductNews'),
'pager' => array(
'header' => '',
'cssFile' => false,
'maxButtonCount' => 5,
'selectedPageCssClass' => 'active',
'hiddenPageCssClass' => 'disabled',
'firstPageCssClass' => 'previous',
'lastPageCssClass' => 'next',
'firstPageLabel' => '<<',
'lastPageLabel' => '>>',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
),
'summaryCssClass' => 'label label-warning',
'columns' => array(
array(
'name' => 'headlines',
'header' => 'Headlines',
'value' => function($data) {
return '<div class="product-news"> <a target="_blank" href="' . $data->link . '" > ' . $data->headlines . '</a></div>';
},
'type' => 'raw',
),
array(
'name' => 'publish_date',
'header' => 'Date',
'value' => function($data) {
return '<span class="news-pub-date">' . $data->publish_date . '</span>';
},
'type' => 'raw',
)
)
));
?>
<!-- Now this script had to be included again in order to make the ajax sorting and pagination work, or else none of the ajax functionality is working. Remember when getting stuck with ajax update in grid views always use this script -->
<script type="text/javascript" src="/ProductAnalysis/assets/dd5f9a70/gridview/jquery.yiigridview.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
jQuery(function($) {
jQuery('[data-toggle=popover]').popover();
jQuery('body').tooltip({
"selector": "[data-toggle=tooltip]"
});
jQuery('#product-news-grid-' + $('#symbol-id').text()).yiiGridView({
'ajaxUpdate': ['product-news-grid-' + $('#symbol-id').text()],
'ajaxVar': 'ajax',
'pagerClass': 'pagination',
'loadingClass': 'grid-view-loading',
'filterClass': 'filters',
'tableClass': 'table table-striped',
'selectableRows': 1,
'enableHistory': false,
'updateSelector': '{page}, {sort}',
'filterSelector': '{filter}',
'url': '/ProductAnalysis/index.php/realTime/AjaxUpdateProductNews',
'pageVar': 'News_page',
'afterAjaxUpdate': function() {
jQuery('.popover').remove();
jQuery('[data-toggle=popover]').popover();
jQuery('.tooltip').remove();
jQuery('[data-toggle=tooltip]').tooltip();
$('#News_headlines').change(function() {
var inputVal = $(this).val();
$('#News_headlines').val(inputVal);
});
}
});
});
/*]]>*/
</script>
Here is the controller action named AjaxUpdateProductNews
public function actionAjaxUpdateProductNews() {
$dataProvider = new News();
$dataProvider->unsetAttributes();
if (isset($_GET['News'])) {
$dataProvider->attributes = $_GET['News'];
}
$id = explode("-", $_GET["ajax"]);
$realTime = RealTime::model()->findByPk($id[count($id) - 1]);
$this->renderPartial('_newsView', array(
'dataProvider' => new News(),
'symbol' => $realTime->symbol,
'id' => $realTime->id,
'headlines' => $_GET['News']['headlines'],
'publish_date' => $_GET['News']['publish_date']
));
}
and here is the view _newsView
<?php
$this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'product-news-grid-'. $id,
'itemsCssClass' => 'table table-striped',
'htmlOptions' => array(
'class' => 'news-datagrid',
),
'dataProvider' => $dataProvider->searchProductNewsSymbol($symbol, $headlines, $publish_date),
'filter' => $dataProvider,
'enableHistory' => false,
'ajaxUpdate' => 'product-news-grid-'. $id,
'ajaxUrl' => Yii::app()->createUrl('/realTime/AjaxUpdateProductNews'),
'pager' => array(
'header' => '',
'cssFile' => false,
'maxButtonCount' => 5,
'selectedPageCssClass' => 'active',
'hiddenPageCssClass' => 'disabled',
'firstPageCssClass' => 'previous',
'lastPageCssClass' => 'next',
'firstPageLabel' => '<<',
'lastPageLabel' => '>>',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
),
'summaryCssClass' => 'label label-warning',
'columns' => array(
array(
'name' => 'headlines',
'header' => 'Headlines',
'value' => function($data) {
return '<div class="product-news"> <a target="_blank" href="'. $data->link .'" > '. $data->headlines .'</a></div>';
},
'type' => 'raw',
),
array(
'name' => 'publish_date',
'header' => 'Date',
'value' => function($data) {
return '<span class="news-pub-date">'. $data->publish_date .'</span>';
},
'type' => 'raw',
)
)
));
?>
Now like i said the filter is showing the result, but the input box is getting cleared after it shows the result. I tried to reinsert the val in the input box using jQuery's change() handler, but it doesn't works.
Please provide any sort of advice on how to retain the search string value in the filter box. Oh, btw other grids on the sites are working flawlessly, so its not a problem with missing files.
Thanks in advance,
Maxx
Ok i've made a mistake in the renderpartial code() which caused this error. Simply changing
'dataProvider' => new News() to 'dataProvider' => $dataProvider fixed the issue. Hope it helps someone who is facing the same issues.
The working controller code
public function actionAjaxUpdateProductNews() {
$dataProvider = new News();
$dataProvider->unsetAttributes();
if (isset($_GET['News'])) {
$dataProvider->attributes = $_GET['News'];
}
$id = explode("-", $_GET["ajax"]);
$realTime = RealTime::model()->findByPk($id[count($id) - 1]);
$this->renderPartial('_newsView', array(
'dataProvider' => $dataProvider,
'symbol' => $realTime->symbol,
'id' => $realTime->id,
'headlines' => $_GET['News']['headlines'],
'publish_date' => $_GET['News']['publish_date']
));
}