I've created a custom page devis and its controller in Prestashop 1.6, but I'm unable to display any columns.
Controller :
class DevisController extends FrontController
{
public $php_self = 'devis';
public $display_column_left = true;
...
}
In Theme configuration, my 'Devis' page appears and the left column is checked :
The "display or not" logic happens in FrontController.php's constructor :
if (isset($this->php_self) && is_object(Context::getContext()->theme)) {
$columns = Context::getContext()->theme->hasColumns($this->php_self);
// Don't use theme tables if not configured in DB
if ($columns) {
$this->display_column_left = $columns['left_column']; // FALSE : why ?
$this->display_column_right = $columns['right_column'];
}
}
I can force the column to display by doing $this->display_column_left = true but it's obviously not the way to do it.
Does someone know why $columns['left_column'] is false ?
Sh*t...
As mentionned by #julien-lachal, the issue was shop-level related.
That means I was browsing the dashboard as "All the shops".
By choosing the desired shop, the left column in theme settings was actually disabled.
Big problems simple fixes...
Related
I want to disable the fields, name and last name, in edit profile Joomla, so that user can not modify them. How can I change this?
The best approach, but not the easiest, is to create an user plugin to override form with a onContentPrepareForm method :
public function onContentPrepareForm($form, $data){
if (!($form instanceof JForm)){
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
$form->setFieldAttribute('name', 'readonly', 'true');
$form->setFieldAttribute('lastname', 'readonly', 'true');
return true;
}
There is not a configuration setting to achieve this.
So the easiest approach is to create a template override for the users view.
In the administrator, open the menu Extensions-Templates-Templates, then select your template and choose "Create Overrides" in the top tab:
In the center column, choose com_users - profile and edit.php
The display is done with a loop, starting at line 59 (as of v. 3.6.5) you want to add code to identify the fields you wish to keep readonly, and simply set their readonly property.
This is the kind of code you would add starting at line 59:
<?php foreach ($fields as $field) : ?>
<?php
if ($field->name == 'jform[name]') {
$field->readonly = true;
}
?>
<?php // If the field is hidden, just display the input. ?>
The $field contains something like this:
We are identifying it by name (well by its field name), then setting its readonly property.
I want to hide the COMPANY field from the Customer Account dashboard (don't ask why).
I found that the address is generated here:
/app/code/core/Mage/Customer/Model/Customer.php
I created a local version to override the core file and then changed public function getAddressesCollection() to the following:
public function getAddressesCollection()
{
if ($this->_addressesCollection === null) {
$this->_addressesCollection = $this->getAddressCollection()
->setCustomerFilter($this)
//->addAttributeToSelect('*')
->addAttributeToSelect('prefix')
->addAttributeToSelect('firstname')
->addAttributeToSelect('middlename')
->addAttributeToSelect('lastname')
->addAttributeToSelect('suffix')
->addAttributeToSelect('street')
->addAttributeToSelect('city')
->addAttributeToSelect('country_id')
->addAttributeToSelect('region')
->addAttributeToSelect('region_id')
->addAttributeToSelect('postcode')
->addAttributeToSelect('telephone')
->addAttributeToSelect('fax')
->addAttributeToSelect('vat_id')
->addAttributeToSelect('vat_is_valid')
->addAttributeToSelect('vat_request_id')
->addAttributeToSelect('vat_request_date')
->addAttributeToSelect('vat_request_success');
foreach ($this->_addressesCollection as $address) {
$address->setCustomer($this);
}
}
return $this->_addressesCollection;
}
I commented out the addAttributeToSelect('*') and replaced it with every customer_address attribute except for COMPANY.
Is this acceptable? It works but I want to know if it will have any obvious negative impact.
Thanks
I need to be able to use different layouts for different categories, selected on the Custom Design tab on the category and Page Layout field.
I'm using Magento 1.9.1.0.
In my config.xml I have:
<global>
<page>
<layouts>
<module_home module="page" translate="label">
<label>Module Home</label>
<template>page/base.phtml</template>
<layout_handle>module_home</layout_handle>
</module_home>
<module_categories module="page" translate="label">
<label>Module Categories</label>
<template>page/base.phtml</template>
<layout_handle>module_categories</layout_handle>
</module_categories>
</layouts>
</page>
...
And in my layouts.xml file I have:
<default>
<reference name="root">...</reference>
</default>
<module_home translate="label">...</module_home>
<module_categories translate="label">...</module_categories>
When I select Module Categories layout from the admin of the category I don't get the changes for module_categories handler, only the ones set on <default>.
If I force it like this:
<catalog_category_view>
<update handle="module_categories" />
</catalog_category_view>
I do get the changes, but I want multiple handlers, selected as Layouts on the admin.
Maybe I'm doing something wrong? Could not find an example for how to do this, maybe you can point somewhere? Thanks!
You've got the right idea with the <update /> directive. Just put it in your category's Custom Layout Update field in the admin, and that category should apply that layout handle. You can still set the page template with the Page Layout field.
The reason you need to explicitly specify the layout handle with the <update /> directive is because Magento's category controller does not use the layout_handle node, whereas other parts of Magento, like Magento's CMS page controller, do use it.
For example, let's look at Mage_Cms_PageController, which is responsible for rendering a CMS page:
public function viewAction()
{
$pageId = $this->getRequest()
->getParam('page_id', $this->getRequest()->getParam('id', false));
if (!Mage::helper('cms/page')->renderPage($this, $pageId)) {
$this->_forward('noRoute');
}
}
Let's dig deeper and look at Mage_Cms_Helper_Page::renderPage(), which calls Mage_Cms_Helper_Page::_renderPage():
protected function _renderPage(Mage_Core_Controller_Varien_Action $action, $pageId = null, $renderLayout = true)
{
$page = Mage::getSingleton('cms/page');
/* ... */
if ($page->getRootTemplate()) {
$handle = ($page->getCustomRootTemplate()
&& $page->getCustomRootTemplate() != 'empty'
&& $inRange) ? $page->getCustomRootTemplate() : $page->getRootTemplate();
$action->getLayout()->helper('page/layout')->applyHandle($handle);
}
/* ... */
if ($page->getRootTemplate()) {
$action->getLayout()->helper('page/layout')
->applyTemplate($page->getRootTemplate());
}
/* ... */
}
We see two important pieces of logic here.
First, _renderPage() calls $action->getLayout()->helper('page/layout')->applyHandle($handle). If you dig even deeper, you'll see that Mage_Page_Helper_Layout::applyHandle() is responsible for applying the appropriate layout_handle as defined by the configuration XML:
public function applyHandle($pageLayout)
{
$pageLayout = $this->_getConfig()->getPageLayout($pageLayout);
if (!$pageLayout) {
return $this;
}
$this->getLayout()
->getUpdate()
->addHandle($pageLayout->getLayoutHandle());
return $this;
}
Second, _renderPage() calls $action->getLayout()->helper('page/layout')->applyTemplate($page->getRootTemplate()). Similar to applyHandle(), applyTemplate() applies the actual page template.
So, this explains why you can depend on the layout_handle as defined in the configuration XML when it comes to CMS pages. Now, let's find out why it's not dependable for categories.
Let's look at Mage_Catalog_CategoryController::viewAction(), which is responsible for displaying a category page:
public function viewAction()
{
if ($category = $this->_initCatagory()) {
$design = Mage::getSingleton('catalog/design');
$settings = $design->getDesignSettings($category);
/* ... */
// apply custom layout update once layout is loaded
if ($layoutUpdates = $settings->getLayoutUpdates()) {
if (is_array($layoutUpdates)) {
foreach($layoutUpdates as $layoutUpdate) {
$update->addUpdate($layoutUpdate);
}
}
}
/* ... */
// apply custom layout (page) template once the blocks are generated
if ($settings->getPageLayout()) {
$this->getLayout()->helper('page/layout')->applyTemplate($settings->getPageLayout());
}
/* ... */
}
elseif (!$this->getResponse()->isRedirect()) {
$this->_forward('noRoute');
}
}
Stripping out all of the default layout logic, we're left with two pieces:
// apply custom layout update once layout is loaded
if ($layoutUpdates = $settings->getLayoutUpdates()) {
if (is_array($layoutUpdates)) {
foreach($layoutUpdates as $layoutUpdate) {
$update->addUpdate($layoutUpdate);
}
}
}
This goes through the category's layout updates (as defined in the Custom Layout Update field in the admin) and applies them. This is why using <update handle="some_handle" /> works.
And...
// apply custom layout (page) template once the blocks are generated
if ($settings->getPageLayout()) {
$this->getLayout()->helper('page/layout')->applyTemplate($settings->getPageLayout());
}
This applies the custom page template, similar to how the CMS page logic did it, using Mage_Page_Helper_Layout::applyTemplate().
Now, notice something missing?
Yup, the category controller does not call Mage_Page_Helper_Layout::applyHandle() to apply the layout_handle as defined in the configuration XML. This means that you can use the Page Layout field to give the category a particular page template, but your layout_update that accompanies the template won't get applied!
Hope this clears up why your layout_update node isn't getting used on the category page the way you would expect it to. Magento is full of odd behavior and inconsistencies like this :)
I apologize in advance for my ignorance of CodeIgniter and the MVC system.
I'm helping a family member with their business website and up until now I've been able to complete most of the required changes just by using logic but now I've hit a dead end. I don't plan to continue supporting them as I'm obviously no CodeIgniter expert. But I'm hoping to leave the website at least functional, so that they can start using it.
I simply want to create a new "page" within the website but it seems impossible. If I can achieve this I think I can figure everything else out on my own.
For example I currently have a "page" for Cancelled Jobs. It the navigation HTML it is linked to like this:
http://localhost/admin/modules/cancelled_jobs
and has a corresponding file here: admin/application/controllers/cancelled_jobs.php
which contains this php code:
class Cancelled_jobs extends CIID_Controller {
public function __construct()
{
parent::__construct();
$this->set_table('job', 'Cancelled Job', 'Cancelled Jobs');
$this->allow_delete = false;
$this->allow_cancel = false;
$this->allow_edit = false;
$this->allow_reactivate = true;
$this->allow_add = false;
$this->overview
->add_item('Job No', 'active', 'job_id')
->add_item('Client', 'active|relationship', 'client.name')
->add_item('Name', 'active', 'name')
->add_item('Status', 'active|relationship', 'job_status.name')
->add_item('Assignee', 'active|relationship', 'team_member.name')
->add_item('Scheduled Date', 'active', 'scheduled_date')
->where("job.cancel_job = '1'")
->order_by('job.created_date DESC');
$this->init();
}
}
I would like to create a new "page" called Closed Jobs.
I've tried copying admin/application/controllers/cancelled_jobs.php and renaming it closed_jobs.php and changing the first line of code to read:
class Closed_jobs extends CIID_Controller {
I then add a link in the navigation HTML:
http://localhost/admin/modules/closed_jobs
However, when clicked, this only results in a "404 Page Not Found" error.
Can anyone point out what I'm missing in the process of creating a new page?
Generally, CodeIgniter URLstructure is:
sitename.com/controller_name/function_name/parameter_1/parameter_2/parameter_3/
You can add as many parameters as you want.
To access
modules/closed_jobs:
Add a new function in the controller modules
function closed_jobs() {
$this->load->view('closed_jobs');
}
And create a view closed_jobs.php
in application/views
Repeat the same for cancelled_jobs
Running Joomla 3.3.0-dev
I'm following the info posted here about adding tag support to a third-party component.
I've added the content type to the #__content_types table and modified my table file like this:
class MycomponentTableElement extends JTable
{
public $tagsHelper = null; // failed when protected and public
public function __construct(&$_db)
{
parent::__construct('#__mycomponent', 'id', $_db);
// Add Joomla tags
JObserverMapper::addObserverClassToClass('JTableObserverTags', 'MycomponentTableElement', array('typeAlias' => 'com_mycomponent.element'));
//$this->_observers = new JObserverUpdater($this); JObserverMapper::attachAllObservers($this); // failed with or without this line
}
I added the tag field in the edit template, and it worked fine-- but when I save an object I get the following error:
Save failed with the following error: Unknown column 'tagsHelper' in 'field list'
What am I missing? There's no other steps (besides front-end steps!) that are mentioned. It seems like I need to modify the model but that info is not applicable.
Thanks
"This Page Needs Copy Editing" and it's really true!
I also follow initial steps as described in page
Register a 'Content type' for the extension view(s)
Add 'Observer methods' to the extension table class(es)
Add 'Tag fields' to the extension edit forms
But to make field tag works on custom extensions I need to explicit set form field value in view file of backend:
$tagsHelper = new JHelperTags;
$this->form= $this->get('Form');
$this->form->setValue('tags', null, $tagsHelper->getTagIds( $this->item->id, 'com_custom.viewname') );
in this way on edit page all seems to work correctly.. surely exist better and more clean method, but until doc page will not be updated, this can help someone!
1- Add tag field to your xml form file or edit template file
2- Modify #__content_types table file:
function __construct(&$db)
{
parent::__construct('#__ir_products', 'id', $db);
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_itemreview.product'));
}
3- Modify model file getItem function:
public function getItem($pk = null)
{
$item = parent::getItem($pk);
if (!empty($item->id))
{
$item->tags = new JHelperTags;
$item->tags->getTagIds($item->id, 'com_yourcomponent.yourmodel');
}
return $item;
}