Monthly Archives: March 2013

Accessing Static Blocks In Magento.

There are Three Ways to add static block in Magento.

  • Inside a template file using PHP
  • Inside a content field of a CMS Page in the Magento admin
  • Inside the Layout Update XML field of a CMS page in the Magento admin

Accessing a Magento Static Block From a PHP Template File

<?php
    // Retrieve the layout object
    $layout = Mage::getSingleton('core/layout');

    // Generate a CMS block object
    $block = $layout->createBlock('cms/block');

    // Set the block ID of the static block
    $block->setBlockId('block-id-in-magento');

    // Write the static block content to screen
    echo $block->toHtml();

Accessing a Magento Static Block From A CMS Page

{{block type="cms/block" block_id="block-id-in-magento"}}

Adding a Static Block to the CMS Page Layout Update XML FIeld

<reference name="content">
  <block type="cms/block" name="block.name">
    <action method="setBlockId"><block_id>block-id-in-magento</block_id></action>
  </block>
</reference>

NOTE : Replace “block-id-in-magento” With your Static Block Name.

Advertisements
Magento

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.

Paste the following code using the HTML option of the WYSIWYG editor:

<!– 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.

How to reset Magento Admin Password ?

To change your Magento admin password, go to your cPanel > phpMyAdmin, select your Magento database, click the SQL tab and paste this query:

     UPDATE admin_user SET
     password=CONCAT(MD5('YOUR NEW PASSWORD'), ':sG')
     WHERE username='Admin_User_name';

Note: You have to change new password in the MD5(‘YOUR NEW PASSWORD’) with your new password, and change *Admin_User_name* to your Magento admin username.

Execute the query by clicking the Go button and your password will be changed.