I have in the magento home content
{{block type="catalog/navigation" template="catalog/navigation/sub_navigation.phtml"}}
This is calling a set of subcategorys of the given parent category ID.
Now I want to influence my $parent_category already from this given block. I found How to pass variable from block to phtml in magento but they don't show the same way of notation.
How to integrate the setData action into the given block notation?
Thanks for your help!
You can pass data like below mention method
{{block type="catalog/product_list" name="Custom Block" category_id="68" column_count="3" product_count="3" template="catalog/navigation/sub_navigation.phtml"}}
after that in phtml file you can get data by below mention method
$this->getCategoryId();
or $this->getData('category_id');
Thanks.
Related
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.
All I want to do is move a search box. This search box is currently displayed in the header, directly next to the logo, and is generated by the following code:
<?php echo $this->getChildHtml('topSearch') ?>
in /app/design/frontend/MYTHEME/default/template/page/html/header.phtml
I would like this search box inline with the navigation links, which are located in top.phtml which is located in another directory. But when I use the code
<?php echo $this->getChildHtml('topSearch') ?>
the search box does not appear. I understand that this is because the meaning of $this has changed, but what I don't understand is how to display the search box? What do I replace $this with?
I tried replacing it with Mage_Page_Block_Html_Header since that was the definition of $this in header.phtml, but to no avail. Can anybody point me in the right direction, or provide an explanation as to how I access methods once the definition of $this has changed?
You need to make layout update and include block topSearch into block containing top.phtml.
Look into app/design/frontend/.../layouts/...xml files, find how topSearch is declared and then find where the block using top.phtml template is declared. Then move topSearch block as a child of top block. I mean add layout xml update like this:
<default>
<reference name="catalog.topnav">
<block type="core/template" name="top.search" as="topSearch" template="catalogsearch/form.mini.phtml"/>
</reference>
</default>
Another solution is try next in your template:
echo $this->getLayout()->getBlock('top.search')->toHtml()
If it would not work then find in layouts topSearch block and try to use in code above name of block instead of alias.
You can read more about Magento view level here: http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/0_-_theming_in_magento/designing-for-magento
Good luck!
I'm using Magento.
I want display and call one phtml file as a link in another phtml file…
I have the new.phtml file on the home page. On that I put one link CHECK ALL which display all new products as category page.. It looks like category page. For that I create another phtml file named newproductpage.phtml which has same code of new.phtml. Now I try to call this newproductpage.phtml file #homepage as CHECK ALL link for that I write this code....
CHECK ALL
But its not working....
thnx..
you call newproductpage.phtml in any phtml file using below code
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('custom/newproductpage.phtml')->toHtml(); ?>
Use the below code for rendering your phtml file in another phtml file.
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('templatefolderpath/filename.phtml')->toHtml(); ?>
For more refinement of your code, you can use the block name and block file name instead of core/template because core/template use the core resources.
You can not call directly one phtml file to another phtml file.
But there are two way to call your phtml file either create one controller and create one action and call action from your anchor tag or create one cms page which call your phtml file.
if you create one module, so in your layout file something you can write
<modulename_controllername_controlleraction>
<reference name="content">
<block type="catalog/product_new" template="custom/newproductpage.phtml" />
</reference>
</module_controllername_controlleraction>
Or you can directly put this code in your cms page content area
{{block type="catalog/product_new" template="custom/newproductpage.phtml"}}
and in anchor tag give cms page link.
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/product/new.phtml')->toHtml(); ?>
you can also check the link.
Display .phtml page in another .phtml page
I believe you and I want to do precisely the same thing. I'm creating a modal from bootstrap and I need to call in a partial using the href attr.
So far, I think this might be possible by creating a page in the CMS and then using something like this:
<li>Home</li>
But honestly, I'm just starting out with Magento and know very little.
you can use iframe for same and load this another page content using AJAX call
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();
Currently, the currency selector is at the top, here’s my development site:
http://nordschleife.metaforix.net/118/118/index.php/kyocera.html
However, I would like to switch the currency selector to just under “Price” heading of the table.
I tried
echo $this->getCurrency();
but there’s nothing. I guess I need some method like getCurrencyHtml(), but it seems that there’s no such a method.
Or must I edit layout files, and how should I go about doing this?
I can show you a way to do this, but in order to understand what's going on, you'll need to have at least a basic grasp of how Magento's layout files work. For that you should read the designer's guide here and a basic explanation of how it all works here.
Now there are several way of handling this, but I think the easiest way is to simply use the existing currency block. Seeing as you'll be putting it in that tiny cell I assume you wont be needing the "Select your Currency" headline. So we'll need a new template.
A block in Magento consists of two files, a block class that does all the work of generating dynamic content and a template file which uses the block class' methods along with some html to create the final result. The heavy lifting of getting the currency options is already done by the block class so if we can use that paired with a new template file we'll be set.
The existing declaration in the layout files and specifically directory.xml is
<block type="directory/currency" name="currency" before="catalog.leftnav" template="directory/currency.phtml"/>
So the template file is app\design\frontend[interface][theme]\template\directory\currency.phtml
Copy that to currency2.phtml and in there remove the heading.
Now to create a new block named "currency2" consisting of the old block class and the new template file we write
<block type="directory/currency" name="currency2" as="currency2" template="directory/currency2.phtml"/>
We'll be using that in /template/catalog/product/list.phtml so open catalog.xml and put the new block declaration under
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
in the appropriate section (I assume catalog_category_default).
Finally open /template/catalog/product/list.phtml and add
<?php echo $this->getChildHtml('currency2'); ?>
where you want the block to appear.