Skip to content

Instantly share code, notes, and snippets.

@0-Sony
Last active December 22, 2015 10:38
Show Gist options
  • Save 0-Sony/0a600f0873955ed38520 to your computer and use it in GitHub Desktop.
Save 0-Sony/0a600f0873955ed38520 to your computer and use it in GitHub Desktop.
Adding manageable pictures in backoffice magento to push in any page.
<!-- local/Namespace/MyModule/etc/adminhtml.xml -->
<?xml version="1.0" encoding="utf-8" ?>
<config>
<acl>
<resources>
<admin>
<children>
<system>
<children>
<config>
<children>
<namespace_module translate="title" module="namespace_module">
<title>namespace_module : Configuration</title>
</namespace_module>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
<!-- local/Namespace/MyModule/etc/config.xml -->
<?xml version="1.0" encoding="utf-8"?>
<config>
<modules>
<Namespace_Module>
<version>0.1.0</version>
</Namespace_Module>
</modules>
<global>
<helpers>
<namespace_module>
<class>Namespace_Module_Helper</class>
</namespace_module>
</helpers>
</global>
</config>
<!-- local/Namespace/MyModule/Helper/Data.php -->
<?php
class Namespace_Module_Helper_Data extends Mage_core_Helper_Abstract {
public function isActivated
{
return Mage::getStoreConfig('namespace_module/active_picture');
}
public function getPictures
{
$isActived = $this->isActivated;
if($isActived)
{
/** adapt $i with your number picture_push**/
for ($i = 1; $i < 2; $i++)
{
$pictures[] = Mage::getStoreConfig("namespace_module/picture_push$i")["image"];
}
return $pictures;
}
}
}
<!-- local/Namespace/MyModule/etc/system.xml -->
<?xml version="1.0" encoding="utf-8" ?>
<config>
<!-- define tabs in system configuration -->
<tabs>
<my_tabs translate="label" module="namespace_module">
<label>My Tabs Label</label>
<sort_order>0</sort_order>
</my_tabs>
</tabs>
<!-- define section in this tab -->
<sections>
<namespace_module translate="label" module="namespace_module">
<label>My Custom Label</label>
<tab>my_tabs</tab>
<frontend_type>text</frontend_type>
<sort_order>100</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<!-- define groups in this section , for each group we define fields -->
<groups>
<active_picture translate="label" module="namespace_module">
<label>Pictures Management</label>
<frontend_type>text</frontend_type>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<use_picture translate="label comment">
<label>Activate pictures</label>
<comment>Pictures will be visible in frontend</comment>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</use_picture>
</fields>
</active_picture>
<picture_push1 translate="label" module="namespace_module">
<label>Image : Push 1</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<image translate="label comment">
<label>Image</label>
<frontend_type>image</frontend_type>
<backend_model>adminhtml/system_config_backend_image</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">my_custom_folder</upload_dir>
<base_url type="media" scope_info="1">my_custom_folder</base_url>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</image>
</fields>
</picture_push1>
<picture_push2 translate="label" module="namespace_module">
<label>Image : Push 2</label>
<frontend_type>text</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<image translate="label comment">
<label>Image</label>
<frontend_type>image</frontend_type>
<backend_model>adminhtml/system_config_backend_image</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">my_custom_folder</upload_dir>
<base_url type="media" scope_info="1">my_custom_folder</base_url>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</image>
</fields>
</picture_push2>
</groups>
</namespace_module>
</sections>
</config>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment