Locate and edit content in Magento 1 block - magento

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 :)

Related

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

Magento - display product reviews on product view page

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"/>

Magento - Adding layered navigation to custom page

I'm working on a magento module that shows particular product collections under a new controller and front-name.
Some of these collections get big, so I'd like to add layered navigation to the side of the page. (And hey, pagination and sort while we're at it.)
I can add the layered navigation block with
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" template="landing/layer.phtml"/>
</reference>
What I get with that is the layered navigation as applied to the whole catalog, with categories broken, and no interface with the on-page product collection.
How would I go about wiring up the layered navigation (and hey, pagination and sort) to this custom product collection?
No answers were forthcoming here, and I changed direction and never completed this path of development. Figured I'd post what I'd learned.
The approach above is sound. The work basically entails recreating the functionality on the catalog or catalogsearch modules. You'll have to subclass the models and blocks of catalog, modifying the product collection and current category.
This post heads vaguely in the right direction, but doesn't get there.
http://www.webdesign-gm.co.uk/news/layered-navigation-on-home-page-or-any-cms-page-magento.php
If you make more headway on this, feel free to post.
I've had a similar request from a client to include specific filterable attributes under a mega menu.
Using a static block i've added this line to everywhere i needed a listing of attributes for specific category
{{block type="core/template" attribute_code="age_specific" category_id="12" template="megamenu-custom-filter-list.phtml"}}
And then the "megamenu-custom-filter-list.phtml"
<?php if($this->getCategoryId() && is_numeric($this->getCategoryId()) && $this->getAttributeCode()): ?>
<?php
$visible_items = 12;
$category = Mage::getModel('catalog/category')->load($this->getCategoryId());
$attrCode = $this->getAttributeCode();
unset($layer);
$layer = Mage::getModel("catalog/layer");
$layer->setCurrentCategory($category);
$attributes = $layer->getFilterableAttributes();
foreach ($attributes as $attribute):
if($attribute->getAttributeCode() != $attrCode){
continue;
}
if ($attribute->getAttributeCode() == 'price') {
$filterBlockName = 'catalog/layer_filter_price';
} elseif ($attribute->getBackendType() == 'decimal') {
$filterBlockName = 'catalog/layer_filter_decimal';
} else {
$filterBlockName = 'catalog/layer_filter_attribute';
}
$result = Mage::app()->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init();
?>
<div>
<h4 class="menu-block-title"><?php echo $this->__($attribute->getFrontendLabel()) ?></h4>
<ul class="menu-attr-list">
<?php $counting = 1; ?>
<?php foreach($result->getItems() as $option): ?>
<?php $optionUrl = $category->getUrl() . "?" . $attribute->getAttributeCode() . "=" . $option->getValue(); ?>
<?php if(!$option->getCount()){ continue; } ?>
<li class="<?php echo ($counting >= $visible_items+1)?"visible-on-showmore":"" ?>" style="list-style: none;">
<a class="cube" href="<?php echo $optionUrl ?>">
<?php echo $option->getLabel() ?> <?php /* (<?php echo $option->getCount() ?>) */ ?>
</a>
</li>
<?php $counting++; ?>
<?php endforeach; ?>
<?php if($counting >= $visible_items+1): ?>
<li class="show-more-menuitem">
<a href="javascript:void(0)" onclick="showMoreMenuItems(this); return false;" class="">
<?php echo $this->__('Visa fler') ?>
</a>
</li>
<?php endif; ?>
</ul>
</div>
<?php endoreach; ?>
<?php endif; ?>
Of course, this can be extended to allow all attributes to be shown and not limit them to 12 (as i did here). Although, i've not build a feature to show this for a custom collection, but i believe that following the "catalog/layer" model and see where the collection was loaded, you can see how to overwrite it and load your own custom collection.

magento 1.7 - adding dynamic content to home page

I would like to add dynamic content to front page of Magento site that looks like this...
I wrote a small "template program" called myPgm.phtml that looks like this:
<?php
$cats = Mage::getModel('catalog/category')->load(2)->getChildren();
$catIds = explode(',' , $cats);
?>
<div class='block block-list'>
<div class='block-title'><strong><span>Goto Category</span></strong></div>
<div class='block-content'>
<ul>
<?php foreach($catIds as $catId): ?>
<ul>
<?php
$category = Mage::getModel('catalog/category')->load($catId);
echo '<li> <a href="' . $category->getUrl() . '">';
echo $category->getName() . '</a></li>';
?>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
I put this in:
app/design/frontend/default/mytheme/template/catalog/navigation/mypgm.phtml
Then in the front page CMS->Pages->Design, I added the following XML reference in side the "&gtreference name="header"&lt" section.
<block type="core/template" name="catalog.category" template="catalog/navigation/mypgm.phtml">
</block>
I put it next to an existing block that does appear on front page.
However my new block does not appear. What am I missing?
I did some additional testing. It works when I put it CMS->Pages->Front-Page->Content as
{{block type="core/template" name="catalog.category" template="catalog/navigation/mypgm.phtml"}}
I also works when I drop the block in this form:
<block type="catalog/navigation" name="catalog.category" template ="catalog/navigation/category.phtml"/>
... in content, left, and right "reference" sections, however not in header... maybe program has not fully boostrapped when header is created????
Try this on your CMS page:
{{block type="core/template" name="giveitaname" template="path/to/your.phtml"}}

How do I get the rating summary in new products section on my homepage?

On my homepage I have “New products” section. I created it with the following code:
<block type="catalog/product_new" name="home.catalog.product.new" alias="product_homepage2" template="catalog/product/new.phtml">
<action method="setColumnCount"><columns>3</columns></action>
<action method="setProductsCount"><count>3</count></action>
</block>
That works fine, but I want also show the rating summary (stars and amount of reviews) om my homepage:
<?php if($_product->getRatingSummary()): ?>
<div class="ratingsum">
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
</div>
The code above gives nothing back. It seems that there are no reviews, but I definitely know that there are reviews!
The problem seems the block type, for new products: catalog/product_new and for bestsellers bestsellers/list, is that possible?
I have also a “best sellers” section on my homepage. There is getting the rating summary no problem.
Also:
$_productCollection=$this->getLoadedProductCollection();
Doesn't work in my new.phtml. It returns no collection/products.
Below is the code to retrieve product rating summary.
$storeId = Mage::app()->getStore()->getId();
$summaryData = Mage::getModel('review/review_summary')
->setStoreId($storeId)
->load('product_id');
if($summaryData->getRatingSummary()){
?>
<div class="rating-box" style="float:left;">
<div class="rating" style="width: <?php echo $summaryData->getRatingSummary().'%'; ?>"></div>
</div>
<?php
}
Just be sure to pass it the right product id number.

Resources