How to add a Contact Us form in Magento
Magento includes contact form functionality by default. A link to a contact form can usually be found in the footer of your Magento installation.Of course, you can add a contact form on any page. All you need to do is:
- Log in to the administrator area.
- Go to CMS > Pages.
- Select the page you want to edit or create a new page.
<!– CONTACT FORM CODE BEGIN–>{{block type='core/template' name='contactForm' template='contacts/form.phtml'}}<!– CONTACT FORM CODE END–>Save the changes and the contact form will appear on the desired page.
"Access denied" issue
As a solution to the "Access denied" issue, you should log out from the Magento admin area and then log in again.If the above does not help, you should reset the admin privileges. This can be done through the Magento admin area > System > Permissions > Roles > Administrators.
Click on the Role Resources option from the left menu and make sure that Resource Access is set to All.
Click on the Save Role button and the permissions will be reset.
How to speed up Magento
Many Magento issues are caused by slow performance. The recommended way to speed up Magento's performance is to enable its Compilation function. The performance increase is between 25%-50% on page loads.You can enable Magento Compilation from your Magento admin panel > System > Tools > Compilation
http://www.siteground.com/tutorials/magento/magento_configuration.htm
------------------------------------------------------------
Config
First things first. A hook has to be defined by adding the code below to the config.xml. By this we’re simply adding an event that will be fired by a dispatch event where a hook, model and method names are required.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| < config > < frontend > < events > < page_block_html_topmenu_gethtml_before > < observers > < my_module > < class >my_module/observer</ class > < method >addToTopmenu</ method > </ my_module > </ observers > </ page_block_html_topmenu_gethtml_before > </ events > </ frontend > </ config > |
Observer
Now, inside the observer file defined in the config.xml a method named addToTopmenu has to be placed. The code below is just an example that adds a top menu item named “Categories” together with its children menu items, category names. That’s right, with this we’re able to create nested menu items!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| public function addToTopmenu(Varien_Event_Observer $observer ) { $menu = $observer ->getMenu(); $tree = $menu ->getTree(); $node = new Varien_Data_Tree_Node( array ( 'name' => 'Categories' , 'id' => 'categories' , 'url' => Mage::getUrl(), // point somewhere ), 'id' , $tree , $menu ); $menu ->addChild( $node ); // Children menu items $collection = Mage::getResourceModel( 'catalog/category_collection' ) ->setStore(Mage::app()->getStore()) ->addIsActiveFilter() ->addNameToResult() ->setPageSize(3); foreach ( $collection as $category ) { $tree = $node ->getTree(); $data = array ( 'name' => $category ->getName(), 'id' => 'category-node-' . $category ->getId(), 'url' => $category ->getUrl(), ); $subNode = new Varien_Data_Tree_Node( $data , 'id' , $tree , $node ); $node ->addChild( $subNode ); } } |
Conclusion
This way of adding new top menu links is easy to implement into Magento and gives us a greater flexibility as opposed to other methods. No fake categories are made and no templates are edited. This method requires some code, but with this programmatic way we’re able to create more than just static menu links. We’re able to create nested menu items, use collections to generate menu items,---------------------------------------------------------------------------------------------
No comments:
Post a Comment