Add image to left column on homepage - image

How do I add an image to the left column on the homepage?

There's a simpler way of doing this:
in the admin go to CMS->Manage Pages
select the home page to edit it
on the left select the second tab(own layout)
as the layout choose either 3 colum or 2 column with left bar
in the xml changes field add this:
<reference name="left">
<block type="core/template" name="unique.id" template="callouts/left_col.phtml">
<action method="setImgSrc"><src>imageUrl</src></action>
<action method="setImgAlt" translate="alt" module="catalog"><alt>alternative text</alt></action>
</block>
</reference>
6. in the xml field change "imageUrl" to the address of your image, "alternative text" to the alternative description and unique.id to a unique id like advertisement.banner.left.

Go to the magento admin site, choose System->Configuration->Advanced->Developer and turn on template tag hints. (Make sure your store name is selected in the Current Configuration Scope dropdown)
You can then go back to your store homepage and you will be able to see which template is used for the left column.
Modify the .phtml template file and add your image there.

Related

Move Shop By content to Right Sidebar in Magento

I have 2columns-right.phtml. how to move Shop By contents [which is in left sidebar] to Right Sidebar
In <catalog_category_layered> handle you need to put layer navigation block in 'Right' block as below:
<catalog_category_layered>
<reference name="right">
<block type="catalog/layer_view" name="catalog.leftnav" before="-" template="catalog/layer/view.phtml"/>
</reference>
</catalog_category_layered>
Add the above xml code in your theme layout local.xml file.
Turn on the Template Path Hint by going to the admin then navigating to System > Configuration > Developer > Debug section. When you are in the configuration page, select the store you are working in by using the top left website/store selector. Wait for the page to reload, and then select the Developer tab.
Select ”Yes” in the select box for Template Path Hints. Click Save. Go back to the store front, and reload. It says so in the template path. The immediate directory name following “template” is the name of the module through which a template is introduced. Copy the corresponding xml file from the base package to your custom design package.
In the layout updates search for .phtml file. You will find an area that looks like this: Change it to say the following instead
(Note that all you are doing is changing left to right)
<reference name="left">
to
<reference name="right">

How link a menu group in magento (via blocks/.phtml files)

I have created a mega menu group. but i stuck at relating it to file.
All i can see form a default one is
<block type="core/text_list" name="megamenu_left" as="megamenu_left" translate="label">
<label>Left Megamenu</label>
</block>
In Home page(Backend > Design Section):
<reference name="megamenu_left">
<block type="megamenu/list" name="megamenu.list.theme" as="megaMenuLeft" template="sm/megamenu/megamenu-left.phtml">
<action method="setConfig">
<values>
<group_id>2</group_id>
<theme>2</theme>
</values>
</action>
</block>
</reference>
And in home page Front view:
<?php echo $this->getChildHtml('megamenu_left') ?>
Things i didn't get is name="megamenu.list.theme" and how this is rendering.
EDITED
how is 'megamenu_left' from xml above is linked with a menu group i created on the backend. The menu group i created on backend just have a name and 'enable/disable' option.
I'm not sure if I understand the question correctly, but the second XML bit is going to look for the reference "megamenu_left" found in the first XML part, and insert the block at that position.
The block itself has the full name "megamenu.list.theme" in the layout, with the optional shortname "megaMenuLeft". It will render the template file "sm/megamenu/megamenu-left.phtml" which will be positioned in the active theme folder such as "app/design/frontend/theme/..".
The template will be using the PHP block from module "megamenu/Block/List.php" so any $this->functionName() calls or variables accessed from within the function comes from that block.
The frontpage will load the block by name from the first part of XML, which in turn will get the content from the second part XML since it's a reference, meaning it will insert itself in the first XML.

Adding a block to magento category page using local.xml

Before posting this, i have looked in to the following, but all of them did not helped me and i was not able to add the block.
magento - adding and positioning a block using local.xml
Magento - Add phtml file to layout block
Magento 1.7:Show category image on category page in full width in a 2 column template
I want to add the category image on top of the page. Currently it is displayed under the product list view, and i want it to be above the left navigation, so that it takes full page width.
I created a template file in mytheme/template/catalog/category/image.phtml and i just added some text "I am here".
After that i add the following xml to my local.xml file under catalog_category_default
<reference name="content">
<block type="catalog/category_view" name="category.image" template="catalog/category/image.phtml"></block>
</reference>
But it is still not working and the text is not displayed there. When this text is displayed, then i will display the category image, but for now i just want to make the block working and display it on top of the page.
Thank you
Maybe your category does not load the layout handle catalog_category_default. There are 2 handles for categories _default and _layered.
To make sure you cover both cases and so you won't duplicate markup try this approach.
define your custom handle.
<my_awsome_category_handle>
<reference name="content">
<block type="catalog/category_view" name="category.image" template="catalog/category/image.phtml"></block>
</reference>
</my_awsome_category_handle>
Then include that handle in both category handles.
<catalog_category_default>
<update handle="my_awsome_category_handle" />
</catalog_category_default>
<catalog_category_layered>
<update handle="my_awsome_category_handle" />
</catalog_category_layered>

Showing custom static block on the custom page Magento

I have a some question about Magento cms static block showing on the custom page.
For example, I have 3 static block (block 1, block 2, block 3) and I need to display block 1 at the Category 1 and subcategories 1, block 2 at the Category 2 and subcategories 2, and block 3 at other pages (home, about, etc)
I try to use Mage::app()->getFrontController()->getRequest()->getRequestUri()
But I received request like "category1.html" and if we going to subcategory of this category - block is changed to default.
If use Mage::app()->getFrontController()->getRequest() I received "catalog/category/view/id/id_number"
I really don't understand how to solve this issue.
Thanks for answer!
You can add a block to a specific part of the page, for a specific category using the Custom Layout Update functionality.
NOTE: If you have a custom theme, the reference name for the footer could be different. This method has been tested to work on the Modern theme included with Magento
Go to Catalog > Manage Categories
Choose the category you want to assign your block to.
Go to the Custom Design tab.
Set Use Parent Category Settings to No
In the Custom Layout Update, insert the following XML
<reference name="bottom.container">
<block type="cms/block" name="my_footer_block">
<action method="setBlockId">
<block_id>my_footer_block</block_id>
</action>
</block>
</reference>
Replace my_footer_block with the Identifier (block_id) of your static block.
Clear your Magento Caches under System > Cache Management and refresh the Category page.
If this does not work, the reference name may not be correct for the theme you are using. You can check the reference name by looking under app/design/frontend/[THEME PARENT]/[THEME CHILD]/layout/page.xml and searching for page/html_footer within the file.
In the file, you will find something like this:
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>bottom-container</value></action>
</block>
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
<block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>
</block>
<block type="core/text_list" name="before_body_end" as="before_body_end" translate="label">
<label>Page Bottom</label>
</block>
</block>
Note the name attribute for the page/html_wrapper block. This is the name references used in the code provided in step Step 5. If it's different than bottom.container, change bottom.container to match what is in your page.xml file.
this might help you
Strategy : Check current page is whether current category is available on current page or not, If available then you can check it's level and depending on that you can show you block
Solution :
$_current_category=$this->getCurrentCategory();
1)get current category and if category not available then show default block
2)if category found get it's level $_current_category->getLevel() and then you can place your block accordingly
Override catalog.xml in you local module
Add in
in content reference
in you catalog/category/voew.phtml
add this code
$_current_category=$this->getCurrentCategory();
if(cond == '1st category') {
echo $this->getChildHtml('block1');
}
Similarly for other blocks
You can simply assign a static block to specific categories using the built in functionality Magento provides.
Go to Catalog > Manage Categories
Click the category you want to assign the block to on the left.
Go to the Display Settings tab
Set Display Mode to either Static block only or Static block with products.
Set CMS Block to the static block you want to display on this category.
Click the Save Category button.
Repeat this step for different categories. You can choose a unique static block, or assign the same one to multiple categories this way.

Magento show sidebar in the customer login page

I want to show a sidebar in the left side of customer account login page. I have successfully placed the sidebar in the product page by calling the navigation bar in catlog.xml file.
But doing the same method with the customer.xml file is not showing the sidebar.
Note
By going through the post "Magento: Display Categories in Sidebar" I had changed my sidebar in product page. But its not working for customer login page.
You need to first tell Magento to use the 2 column template for the Customer Account Login page - as standard it uses the 1 column template file and as such wont have either the left or right structural blocks for your sidebar to go into.
Simple to do - best practice would be to add the layout instruction to an existing or create a local.xml file in your app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout/ folder.
Using the handle <customer_account_login> so as to reference the login page, add the following to local.xml
<customer_account_login>
<reference name="root">
<action method="setTemplate"><template>page/2column-left.phtml</template></action><!-- Tells Magento to use 2 Column Left page template -->
</reference>
</customer_account_login>
This will use the template with a left sidebar.
Then, also within the same <customer_account_login> handle call in your block to the left structural block...
<customer_account_login>
<reference name="root">
<action method="setTemplate"><template>page/2column-left.phtml</template></action><!-- Tells Magento to use 2 Column Left page template -->
</reference>
<reference name="left"><!-- Tells Magento to place the following content in the left structural block-->
<!-- Your Block Goes Here -->
</reference>
</customer_account_login>
Done.
If you're not comfortable working in a local.xml file you can just amend the content of the <customer_account_login> handle in customers.xml to use the above mentioned "root" and "left" - you'll find it calls the page/1column.phtml file under root and of course wont yet have a <reference name="left">.

Resources