Magento catalog - Duplicate category using static block - php

In the web-shop i'm creating we want the customers to see the category new as they are landing in the shop.
Our configuration in the whole catalog is an layout of 4 items next to each other, like below:
four items in one row
*sorry i am not yet allowed to post pictures :(
I've made an static block in Magento using the following code:
{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" category_id="7" template="catalog/product/list.phtml"}}
But when i call this block at the place I wan't it to display, it does not use the correct layout:
3 items in one row, two rows
*sorry i am not yet allowed to post pictures :(
It only put's 3 items next to each otter. I've already tried tweaking the css but that's not the problem. The page code shows that it is put in another row:
<ul class="products-grid first odd"> (the first row)
<ul class="products-grid last even"> (the second row)
My guess is that when i call the block it sets the display to 3 items a row, but i can't figure out where that configuration is located.

Way 1:
for you to use modificated template catalog/product/list.phtml
Create new template from this one and call it list-home.phtml and where you have grid mode view you must have something like this:
<?php $_columnCount = $this->getColumnCount(); ?>
replace this with
<?php $_columnCount = 4; ?>
Way 2: Add this block via layout or custom layout in admin area and add to it params like:
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
Sorry - second way would not work via static block - you can add this w/o static block directly in Layout Update XML in CMS home page, also I don't understand for what you using static block for this if you can add this code for block directly in CMS Page content too

Related

Magento: how to call static block in category page within content

I am trying to call a static cms block with id BLOCKID from within the content section of the category. I tried using the following and it doesn't work:
{{block type="cms/block" block_id="BLOCKID"}}
I am able to call it using Custom Layout Update using the following code but it doesn't allow me control over the location where within content it will appear.
<reference name="content">
<block type="cms/block" name="BLOCKID">
<action method="setBlockId"><block_id>BLOCKID</block_id></action>
</block>
</reference>'
There is a specific section in my text located in the content section where I want this block to appear.
Any help would be appreciated.
If you want to stick a static block into category content, there is an easy workaround. To keep things straight for this example, let's say the category is "Cameras" and your static block is "camera-deals".
Go to your category, copy all of the content.
Create a new static block named "cameras-content" or something similar
Paste your category content into this new static block, insert your existing "camera-deals" static block where you want it to go. Save
Return to the category, delete the content that you previously copied
In the Display tab, set Display Mode -> Static Block (can be either just the static block or with products, both work)
Choose the "cameras-content" for your static block (this block can have variables and static blocks inside of it.) Save
Basically, it's easy to call files in the media folder, variables, blocks, and widgets from a static block...but out of the box you can't do that in category content. So just don't do that, haha. Have your category refer to a static block and then do all of your fancy things in that block.

magento static block error in admin

I have added the 2 static block codes to a CMS page in magento inside a DIV.
<div class="WTcontainerTop">
{{block type="cms/block" block_id="TW_intro"}}
{{block type="cms/block" block_id="TW-Tour"}}
</div>
After saving the page, it looks like the below although the frontend page looks fine.
<div class="WTcontainerTop">http://everydaycashmere.com/index.php/admin/cms_wysiwyg/directive/___directive/e3tibG9jayB0eXBlPSJjbXMvYmxvY2siIGJsb2NrX2lkPSJUV19pbnRybyJ9fQ,,/key/ba3c67e3bc929ae08551768624139371/ {{block type="cms/block" block_id="TW-wardrobe-Grand-Tour"}}</div>
I have tried to fix in a number of times and I don't get this error on other pages. Can anyone help please.
I don't know that the method of adding static block you tried is correct or not.You can do it by:
Clicking on "Insert Widget" on "Content" portion of 'CMS Page'.
Then select the Widget type to "CMS static Block".Then select the static block you want to add.
This process will add a static block in your cms page.
Hope this will help.

Ajax in magento (load product view block)

What I want to achieve:
Clicking on a product link/image (at least in certain areas) to open a pop-up with the full product information (basically all the contents of the product view page).
What I did/tried so far:
created all the stuff outside the ajax php code (the module, links, templates, rewrites)
created the ajax controller (which can be accessed with a link similar to: http://test.com/index.php/ajaxproductview/ajax/index/id/2 ).
to follow various tutorials ( like this or this ) - that helped me get this far. But I don't want to load my custom block, I want the default product view block(s).
tried to add some code in the indexAction(). It gets there, but the code fails. I don't get any errors/notices/reports, just what it seems like an infinite loop that kills my processor.
$body = $this
->getLayout()
->createBlock('product.info') // taken from catalog.xml
->toHtml();
$this->getResponse()->setBody($body);
All the other pages work fine, and it's a fresh magento with only magneto and my module installed and activated.
My AJAX function simply gets this HTML response, puts it into a div, and opens a pop-up.
My question(s) is(are) - how can I set the product id, so the block knows what product to load, and how can I load this block correctly. I also tried something similar to this:
Thank you.
PS: I also tried this:
$layout = $this->getLayout();
$update = $layout->getUpdate();
$update->load('catalog_product_view');
$layout->generateXml();
$layout->generateBlocks();
$output = $layout->getOutput(); // $output is an empty string
The Product controller uses a helper to set the active product. You should be able to do the same in your controller!
Try this before you do your layouting:
$productId = (int) $this->getRequest()->getParam('id');
Mage::helper('catalog/product')->initProduct($productId, $this);
Another thing to be aware of:
If you add a block like the product.info block. It needs additional child blocks if it calls them in its template file.
It would be easiest to use a custom layout xml file. You can then add a specific layout for your action handle (your action handle consists of your routers node in your module's etc/config.xml file under <frontend><routers>, e.g. <Yourmodule> node, make sure to lowercase it! And then with underscores add the controller name and action name, in your case index_index) like this:
<yourmodule_index_index>
<remove name="right"/>
<remove name="left"/>
<block type="catalog/product_view" name="root" output="toHtml" template="catalog/product/view.phtml">
<!-- Add all the child blocks you need -->
</block>
</yourmodule_index_index>
This makes the view.phtml the root block which renders itself using its toHtml method.
Therefore, in your controller action, all you need is my two lines above and then:
$this->loadLayout();
$this->renderLayout();

change my account menu position in magento

I have created custom module which added link in Left navigation menu of My Account Page. Every things is handle By modules Layout.xml.
But My Module link is appeared at Last in position i.e after News letter Subscription. I want to add this after "My Order" Menu.
How can I do this. Please help me.
Thanks
Pravin
In the XML file you can set your block to come before or after another block.
In the layout XML file add the following attribute to the block:
before="name_of_block"
Or:
after="name_of_block"
So your line would look something like this:
<block type="some/type" before="some_other_block_name" template="some/path/to/template.phtml" />
If you want it to come before any other block (or after every other block) use the following:
before="-"
Or:
after="-"

add code snippet in magento core

I'm running magento 1.4 and I'm trying to display an overlayer banner on all the pages in my magento store. In which file should I add the code snippet for the banner so that the it gets displayed on all pages?
BTW: the code snippet is actually some a short php if function + an OpenX Javascript Tag
From this search:
Go to /admin/cms_block/ and add a block. Remember the identifier.
In your code add <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>
There you go…
For javascript to be included on every page have a look at page.xml layout <default> section. For PHP code see which blocks are included on the page and create a block after (or before) one of them

Categories