Not able to go to How to create New Static Block page

I am not able to open the How to create New Static Block (srkfriends, you do not have permission to access this page. This could be due to one of several reasons. How it can be i am member for Joomla Template and Magento both. Please help

1 answer

Profile photo of tomc 0.00 $tone March 16, 2012
Public

I am not able to open the How to create New Static Block (srkfriends, you do not have permission to access this page. This could be due to one of several reasons. How it can be i am member for Joomla Template and Magento both. Please help

The basic steps to add a static block in Magento is as follows:

1. Log into your Magento store’s admin
2. Navigate to CMS>Static Blocks
3. Click Add New Block in the top right corner
4. Give your block a recognizable Block Title such as Social Media Links or “Fall Sale Banner”.
5. Give your block an Identifier which will be used to call the block. Make sure the Identifier is all lowercase and separated by underscores to follow Magento’s nomenclature i.e. your_block_id
6. Choose what store view the block belongs to. Just leave as All Store Views -- unless you have a good reason not to
7. Set Status to Enabled
8. Click Save Block or Save and Continue Edit to save your settings.

You’ve set up your block . . . but NOW you need to display the block on your site.
There are several ways to accomplish this . . . .

1.XML
You can embed this code in app > design > frontend > default > your_theme > layout. Open the appropriate the file, lets say catalog.xml, and plunk the following code in the block for our category view:

Code:


<block type=”cms/block” name=”your_block_id” before=”-”>
<action method=”setBlockId”>your_block_id</action></block>


This code will place the block “your_block_id” that you have created in the admin above the content on the category pages (notice the before=”-” attribute, which makes sure your block gets displayed before the rest of the content). This is perfect for a seasonal banner that could advertise a current sale on all product listings.


Controlling static blocks with XML is geared for content that will remain in a consistent position in your theme.

Sometimes however you gotta get down and dirty and place your CMS static block inline in your template. That’s where the next method comes in.

2. PHP
Adding your static block inline with PHP is the quickest way to get your block in your template. Let’s say you want to add a quick blurb about your return policy right after the “Add to Cart” button. The client needs to be able to occassionaly update this blurb from time to keep it current.

So you open your template file that contains the “Add to Cart” button app > design > frontend > default > your_theme > template > catalog > product > view > addtocart.phtml

Find the<button> tag and right afterwards add the following code:

Code:


<?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘your_block_id’)->toHtml(); ?>


This code will add the block “your_block_id” right after the button. Jobs done. This method is perfect for getting into those nooks and crannies in Magento’s vast and awkward file structure.

3. Shortcode
This method is used when you need to pull in a static block while in Magento’s admin creating CMS pages or other static blocks. A possible example would be injecting contact information into multiple CMS pages.

So you create a contact static block, and then can insert the contact info on the contact us page, your privacy policy page, customer service page, etc. If the contact info changes, you simply update the static block and the changes will be reflected across all your CMS pages.

Code:

{{block type=”cms/block” block_id=”your_block_id”}}


This code will place the block “your_block_id” inline in your CMS page.

The following videos may also assist you further . . . .

STATIC BLOCKS in Magento

How To Create A Static Block in Magento

#1

Please login or Register to Submit Answer

Written By

Comments