Magento - display product reviews on product view page - magento

I am having difficulty placing the product reviews on the main product view at a specific location. I can load them in the content area, but not at the specific location I require (within some of the view mark-up).
I have a local.xml with the following in it:
<catalog_product_view>
<reference name="content">
<block type="review/product_view_list" name="product.info.product_additional_data" as="reviews" template="review/product/view/list.phtml"/>
</reference>
<catalog_product_view>
The above loads the reviews after all other content - as might be expected, due to content not being a templated block.
I have tried defining the blocks outside of the content reference, and placing this at the relevant point:
<?php echo $this->getChildHtml('reviews') ?>
For clarity, here is where I need the block to appear in view.phtml:
<div class="product-collateral">
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
<div class="box-collateral <?php echo "box-{$alias}"?>">
<?php if ($title = $this->getChildData($alias, 'title')):?>
<h2><?php echo $this->escapeHtml($title); ?></h2>
<?php endif;?>
<?php echo $html; ?>
</div>
<?php endforeach;?>
<?php echo $this->getChildHtml('upsell_products') ?>
<?php echo $this->getChildHtml('product_additional_data') ?>
<?php echo $this->getChildHtml('reviews') ?>
</div>
Unfortunately, this doesn't output anything at all. I'm fairly new to Magento, and I'm at a loss how to achieve the above.

You can try leaving the code as in your example and include and use the attribute before, or after.
This allows you to position a block in regards to another block within that reference.
Ex: <block type="review/product_view_list" name="product.info.product_additional_data" as="reviews" template="review/product/view/list.phtml" before="product.description"/>

Related

Locate and edit content in Magento 1 block

I am very new to Magento. I have an old Magento 1 site that someone else has built and I am trying to edit content that is on a particular page, called 'Trade'.
In the backend, I have found the page: CMS > PAGES > TRADE.
The 'CONTENT' tab has some of the pages content written in it, but not the part I want to edit.
The 'DESIGN' tab has the following code, which I believe is where the content I want to edit is located:
<reference name="content">
<block type="core/template" name="boards" template="cms/trade.phtml" />
</reference>
When I go to 'TRADE.PHTML' in my files, I have the following code:
<?php
$page = Mage::getSingleton('cms/page');
$advanced_fields = Mage::helper('core')->jsonDecode($page->getAdvancedFields());
$cms_fields = array();
foreach($advanced_fields as $field){
$name = $field['name'];
$content = $field['content'];
$cms_fields[$name] = $content;
}
$filter = new Mage_Widget_Model_Template_Filter();
?>
<div class="board">
<?php if(isset($cms_fields['board_1'])){ ?>
<div class="board_left board_inner">
<?php echo $filter->filter($cms_fields['board_1']); ?>
</div>
<?php } ?>
<?php if(isset($cms_fields['board_2'])){ ?>
<div class="board_right board_inner">
<?php echo $filter->filter($cms_fields['board_2']); ?>
</div>
<?php } ?>
</div>
I can not for the life of me figure out where to edit this little bit of content, and it's taking up way too much time.
A point in the right direction would be a great help, as I'm sure this is pretty simple and obvious to you Magento devs! Help a newbie out :)

Magento Static block now showing up in CMS Page

Hy ! I'm trying to display the categories on a cms page.I've tried all the solution on the web but none is working for me. The last one i've tried is this.
1.I've added this code in content tab of my cms page :
{{block type="catalog/navigation" template="catalog/category/list.phtml"}}
2.I've created the list.phtml and put the file on app/design/theme-name/template/catalog/category.
Here is the code pf my file
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $open = $this->isCategoryActive($_category); ?>
<?php
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
if ($immagine = $this->getCurrentCategory()->getImageUrl()):
?>
<div class="catalog-image">
<div>
<a href="<?php echo $this->getCategoryUrl($_category)?>">
<img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="313" height="151" />
</a>
</div>
<div class="left"><h2><?php echo $_category->getName()?></h2></div>
</div>
<?php endif; ?>
<?php endforeach; ?>
What I'm doing wrong ? Thanks !
Add this code in content tab of your cms page:
{{block type="core/template" template="page/categories-list.phtml"}}
Create a file in the theme such "categories-list.phtml"
path: app/design/theme-name/template/page/categories-list.phtml
In this file, write the following code in order to get a collection of all the categories:
<?php
$categories = Mage::getModel('catalog/category')
->getCollection()
->addAttributeToSelect('*')
->addIsActiveFilter();
?>
If you want only some categories of parent, use the following code:
<?php
$parent_category_id = 5; // this is ID of parent category
$categories = Mage::getModel('catalog/category')->getCategories($parent_category_id);
?>
To display categories on the screen, use loop, look below:
<?php foreach ($categories as $category): ?>
<p><?php echo $category->getImageUrl(); ?></p>
<p><?php echo $category->getName(); ?></p>
<?php endforeach; ?>
If you use the categories of the parent category to display the image, use the following code:
Mage::getModel('catalog/category')->load($category->getId())->getImageUrl();
Create a folder under catalog with name navigation and put your list.phtml file there it will work.
{{block type="core/template" template="catalog/navigation/list.phtml" category_id="507" }}
Category Display Mode shuould be in static block in display setting.

Magento: how to retrieve the content of a Category CMS Block from a CMS layout?

In magento one could define his own CMS Block for a Category.
Question:
I would like to be able to get the contents of the static block, defined for a category and use this block anywhere in my phtml layouts.
EDIT:
Approaching the problem from the wrong angle.
I could resolve this by using
getLayout()->createBlock('cms/block')->setBlockId('category_banner')->toHtml(); ?>
Already did some searches but I was unable to find the solution so far.
In catalog/category/view.phtml we have:
<?php if ($this->isContentMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php elseif ($this->isMixedMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php echo $this->getProductListHtml() ?>
<?php else: ?>
<?php echo $this->getProductListHtml() ?>
<?php endif; ?>
The getCmsBlockHtml() ?> returns the CMS block defined in Category Management. This is a static block one can assign himself.
Is there a way to get this block from a layout by calling a specific method?
<block type="cms/block" name="block_name">
<action method="setBlockId"><block_id>cms_block_id</block_id></action>
</block>

how do I alter a link in the my account navigation column in magento?

im trying to alter the navigation links in the my account section of my magento site currently they look like this:
I turned on debug template paths so I can locate where it came from but it just sent me to navigation.phtml, which was just some php code the echos the links in a list form see below.
<div class="block block-account">
<div class="block-title">
<strong><span><?php echo $this->__('My Account'); ?></span></strong>
</div>
<div class="block-content">
<ul>
<?php $_links = $this->getLinks(); ?>
<?php $_index = 1; ?>
<?php $_count = count($_links); ?>
<?php foreach ($_links as $_link): ?>
<?php $_last = ($_index++ >= $_count); ?>
<?php if ($this->isActive($_link)): ?>
<li class="current<?php echo ($_last ? ' last' : '') ?>"><strong><?php echo $_link->getLabel() ?></strong></li>
<?php else: ?>
<li<?php echo ($_last ? ' class="last"' : '') ?>><?php echo $_link->getLabel() ?></li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
My goal is simple to rename "My Wishlist" to "My Sample Request" any ideas on how to achieve this ?
If renaming is only the issue than it is very simple.
You just edit the name in the "app/design/frontend/base/default/layout/wishlist.xml".
you will search for below code.
<customer_account>
<!-- Mage_Wishlist -->
<reference name="customer_account_navigation">
<action method="addLink" translate="label" module="wishlist" ifconfig="wishlist/general/active"><name>wishlist</name><path>wishlist/</path><label>My Wishlist</label></action>
</reference>
</customer_account>
change the label "My Wishlist" to "My Sample Request".
This will work.But its not the best way to achieve this.First Override the "wishlist.xml" to your theme and then only make a change.
Hope this will help.
you dont need to do this from xml file , just open the
`app/locale/en_US/Mage_XmlConnect.csv
and around line 601 you wil see a "My Wishlist","My Wishlist"
you can change from there. if you will change in xml file than in multilangual site it will same for all languages. So change from translate file.
thanks
$this->getLinks() is heart of that template. It retrieves all links as an array and then loop through it and display each item. So the array returned by that code is actually constituted by another method addLink(). It normally use in layout files. My guess is, you need to alter that name in layout file.
File : app\design\frontend\<package>\<theme>\layout\customer.xml
You can see many code like this
<action method="addLink" translate="label" module="customer">
<name>account</name>
<path>customer/account/</path>
<label>Account Dashboard</label>
</action>
Here label is the part that you need to change.
So check for this code in customer.xml file. Find the code that generate "Wisthlist" link. Then change the label part according to your need

Call a block in another template

I just create a module name referral. Now I want to place the referral block to another module template file name success.phtml. Can it be done?
referral.xml(in referral module)
<?xml version="1.0"?>
<layout version="0.1.0">
<checkout_onepage_success>
<reference name="checkout.success">
<block type="referral/referral" name="referralCallLink"><action method="referralCallLink"></action></block>
</reference>
</checkout_onepage_success>
<!--block type="referral/referral" name="referralAddSession"><action method="referralAddSession"></action></block-->
</layout>
success.phtml
<?php if($hasBoughtMCash): ?>
<div> Your
<?php echo implode(', ',$hasBoughtMCash); ?>
purchase is successful.
</div>
<?php endif; ?>
<h2>Share in Facebook and Earn for Free MCash!</h2>
<?php echo $this->getChildHtml(); ?>
Referral.php(block)
public function referralCallLink() //success page
{
...
$collection7 = Mage::getModel('referral/referrallink')->getCollection();
$collection7->addFieldToFilter('customer_id', array('eq' => $cust_id));
$collection7->addFieldToFilter('grouped', array('eq' => $grouped));
foreach($collection7 as $data3)
{
$product = $data3->getData('product');
$link = $data3->getData('link');
$imageurl = $data3->getData('url');
//facebook
$title=urlencode('Shop, Save and Get Rewarded at MRuncit.com');
$url=urlencode($link);
$summary=urlencode('I just bought '.$product.' from MRuncit.com and earned some MReward Points!');
$image=urlencode($imageurl);
?>
<p>
<a href="http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[summary]=<?php echo $summary;?>&p[url]=<?php echo $url; ?>&p[images][0]=<?php echo $image;?>','sharer','toolbar=0,status=0,width=548,height=325');" target="_blank">
<img src="<?php echo $imageurl;?>" width="30">
I just bought <?php echo $product; ?> from MRuncit.com and earned some MReward Points!
</a>
</p>
<?php
}
}
Results
You should create the block as child of the success block in your layout XML:
<layout_handle_of_the_success_page>
<reference name="name_of_the_success_block_in_layout">
<block type="your/referral_block" />
</reference>
</layout_handle_of_the_success_page>
Then you can insert the following line in success.phtml:
<?php echo $this->getChildHtml('referral'); ?>
There are some names in the example XML that you have to replace with your own:
layout_handle_of_the_success_page - you will find it in the layout XML of the corresponding module. It should be in the form module_controller_action --> checkout_onepage_success
name_of_the_success_block_in_layout - also from the layout XML, look for the block with the success.phtml template and its name attribute --> checkout.success
your/referral_block - that's the class alias of the block that you want to insert in the form module/class --> referral/referral

Resources