Magento allow user to change theme colors via admin panel -
ok want allow end user (who won't know code) able change theme colors i'm creating. saw can create custom variables, it's not efficient put css php file.
so how go user can put hex code of color navigation background or button background or whatever.. via admin panel?
one way of doing adding customer attribute , letting customer change it.
adding customer attribute can achieved sort of method:
public function addcustomerattribute($params){ try{ $setup = mage::getmodel('customer/entity_setup', 'core_setup'); $setup->addattribute('customer', $params['code'], array( 'type' => $params['type'] , 'input' => $params['input'], 'label' => $params['name'], 'global' => $params['scope'], 'visible' => 1, 'required' => $params['required'], 'user_defined' => 1, 'default' => $params['defaultvalue'], 'visible_on_front' => $params['visible_on_front'], 'used_in_forms', array('adminhtml_customer','customer_account_edit') )); mage::getsingleton('eav/config') ->getattribute('customer', $params['code'] ) ->setdata( 'used_in_forms', array('adminhtml_customer','customer_account_edit') ) ->save(); return true; }catch(exception $e){ throw new exception('probleme de création d\'attribut client ' . $e->getmessage()); } }
then if customer logged in, let him change value , save it.
you can retrieve with
$customercolor = mage::getsingleton('customer/session')->getcustomer()->getattributecode()
and use value set css classes on templates
Comments
Post a Comment