Add Structural Block - Magento 1.9 - magento

i have a problem with structural block in magento 1.9.
This is my local.xml layout file:
<layout version="0.1.0">
<default>
<reference name="root">
<block type="core/template" name="pluma" as="pluma" template="pluma/helloworld/simple_page.html"/>
</reference>
</default>
This is my 1column.phtml template file:
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
<?php echo $this->getChildHtml('global_notices'); ?>
<pre><?php echo $this->getChildHtml('pluma'); ?></pre>
<div class="page">
<?php echo $this->getChildHtml('header') ?>
<div class="main-container col1-layout">
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
</div>
</div>
<?php echo $this->getChildHtml('footer_before') ?>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('global_cookie_notice') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
And this is my template file (very simple):
<h1 style="background-color:yellow">Hello New Reference!</h1>
Magento response only "empty" tags. I don't understand my error..
Thanks in advance..

Try to use .phtml (default template files for magento) file instead of .html :
<layout version="0.1.0">
<default>
<reference name="root">
<block type="core/template" name="pluma" as="pluma" template="pluma/helloworld/simple_page.phtml"/>
</reference>
</default>
Also make sure you change the name in pluma/helloworld : simple_page.html -> simple_page.phtml

Related

Magento 1.9.2.3 - Wishlist issue

would like to ask you some help regarding an issue I'm having in the wishlist section. When we add a product as favourite, this message appears as an error.
Fatal error: Call to a member function setItems() on boolean in /home2/***/public_html/app/design/frontend/base/sinprecio/template/wishlist/view.phtml on line 43
This is the code in the view.phtml
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<div class="my-wishlist">
<div class="page-title title-buttons">
<?php if ($this->helper('wishlist')->isRssAllow() && $this->hasWishlistItems()): ?>
<?php echo $this->__('RSS Feed') ?>
<?php endif; ?>
<h1><?php echo $this->getTitle(); ?></h1>
</div>
<?php echo $this->getMessagesBlock()->toHtml() ?>
<form id="wishlist-view-form" action="<?php echo $this->getUrl('*/*/update', array('wishlist_id' => $this->getWishlistInstance()->getId())) ?>" method="post">
<?php echo $this->getChildHtml('top'); ?>
<fieldset>
<?php if ($this->hasWishlistItems()): ?>
<?php echo $this->getBlockHtml('formkey');?>
<?php $this->getChild('items')->setItems($this->getWishlistItems()); ?>
<?php echo $this->getChildHtml('items');?>
<script type="text/javascript">decorateTable('wishlist-table')</script>
<?php else: ?>
<p class="wishlist-empty"><?php echo $this->__('You have no items in your wishlist.') ?></p>
<?php endif ?>
<div class="buttons-set buttons-set2">
<?php echo $this->getChild('control_buttons')->toHtml();?>
</div>
</fieldset>
</form>
<form id="wishlist-allcart-form" action="<?php echo $this->getUrl('*/*/allcart') ?>" method="post">
<?php echo $this->getBlockHtml('formkey') ?>
<div class="no-display">
<input type="hidden" name="wishlist_id" id="wishlist_id" value="<?php echo $this->getWishlistInstance()->getId() ?>" />
<input type="hidden" name="qty" id="qty" value="" />
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var wishlistForm = new Validation($('wishlist-view-form'));
var wishlistAllCartForm = new Validation($('wishlist-allcart-form'));
function calculateQty() {
var itemQtys = new Array();
$$('#wishlist-view-form .qty').each(
function (input, index) {
var idxStr = input.name;
var idx = idxStr.replace( /[^\d.]/g, '' );
itemQtys[idx] = input.value;
}
);
$$('#qty')[0].value = JSON.stringify(itemQtys);
}
function addAllWItemsToCart() {
calculateQty();
wishlistAllCartForm.form.submit();
}
//]]>
</script>
</div>
<?php echo $this->getChildHtml('bottom'); ?>
<div class="buttons-set">
<p class="back-link"><small>« </small><?php echo $this->__('Back') ?></p>
</div>
And this is the line 43
<?php $this->getChild('items')->setItems($this->getWishlistItems()); ?>
Any clue? I'm kinda lost with this error. Thanks in advance!
Hi Plz check your wishlist.xml with below xml in your theme layout
<wishlist_index_index translate="label">
<label>Customer My Account My Wishlist</label>
<!-- Mage_Wishlist -->
<update handle="customer_account" />
<reference name="my.account.wrapper">
<block type="wishlist/customer_wishlist" name="customer.wishlist" template="wishlist/view.phtml">
<action method="setTitle" translate="title">
<title>My Wishlist</title>
</action>
<block type="wishlist/customer_wishlist_items" name="customer.wishlist.items" as="items" template="wishlist/item/list.phtml">
<block type="wishlist/customer_wishlist_item_column_image" name="customer.wishlist.item.image" template="wishlist/item/column/image.phtml" />
<block type="wishlist/customer_wishlist_item_column_comment" name="customer.wishlist.item.info" template="wishlist/item/column/info.phtml">
<action method="setTitle" translate="title">
<title>Product Details and Comment</title>
</action>
</block>
<block type="wishlist/customer_wishlist_item_column_cart" name="customer.wishlist.item.cart" template="wishlist/item/column/cart.phtml">
<action method="setTitle" translate="title">
<title>Add to Cart</title>
</action>
<block type="wishlist/customer_wishlist_item_options" name="customer.wishlist.item.options" />
</block>
<block type="wishlist/customer_wishlist_item_column_remove" name="customer.wishlist.item.remove" template="wishlist/item/column/remove.phtml" />
</block>
<block type="core/text_list" name="customer.wishlist.buttons" as="control_buttons">
<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.share" template="wishlist/button/share.phtml" />
<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.toCart" template="wishlist/button/tocart.phtml" />
<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.update" template="wishlist/button/update.phtml" />
</block>
</block>
</reference>
<reference name="right">
<action method="unsetChild"><name>wishlist_customer_sidebar</name></action>
</reference>
</wishlist_index_index>

Moving toplinks to another block in Magento

I'm trying to move the toplinks to a static block that I created above the header. Currently, I'm only getting the "Log Out" link instead of all of the top links (My Account, My Wishlist, My Cart, and Checkout). How can I get all these links into the static block?
2columns-right.phtml
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
<?php echo $this->getChildHtml('global_notices') ?>
<div class="page">
<div><?php echo $this->getChildHtml('newreference') ?></div>
<?php echo $this->getChildHtml('header') ?>
<div class="main-container col2-right-layout">
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
<div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div>
</div>
</div>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('global_cookie_notice') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>
newReference.phtml
<p class="welcome-msg"><?php echo $this->getChildHtml('welcome') ?> <?php echo $this->getAdditionalHtml() ?></p>
<div class="quick-access">
<?php echo $this->getChildHtml('topLinks') ?>
</div>
local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<block type="core/text_list" name="newreference" as="newreference" translate="label">
<label>New Reference</label>
</block>
</reference>
<reference name="newreference">
<block type="core/template" name="newreferenceblock" template="newreference.phtml">
<block type="page/template_links" name="top.links" as="topLinks"/>
</block>
</reference>
</default>
</layout>
Try this
<reference name="newreference">
<block type="core/template" name="newreferenceblock" template="newreference.phtml">
<block type="page/template_links" name="top.links" as="topLinks"/>
</block>
</reference>
change this to
<reference name="newreference">
<block type="core/template" name="newreference" template="newReference.phtml">
<block type="page/template_links" name="top.links" as="topLinks"/>
</block>
</reference>

How to add font awesome icons in top links of Magento

I am using boilerplate template for Magento and there is font awesome already included with this template. I create a bootstrap button for my car in top links by adding a class="btn btn-primary" in Links.php and now I am facing an issue when trying to add the cart icon from font awesome...
I would like to add this code in front of "My Cart (2 items)" top links:
My cart
I have tried few things without success...
thanks for any help
edit: this is what my top.links.phtml look like and I can't figure out how to add your code:
<?php if($toplinks && is_array($toplinks)): ?>
<ul class="links">
<?php echo $this->getChildHtml() ?>
<?php foreach($toplinks as $_toplink): ?>
<li<?php if($_toplink['first']||$_toplink['last']): ?> class="<?php if($_toplink['first']): ?>first<?php endif; ?><?php if($_toplink['last']): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_toplink['liParams'] ?>><?php echo $_toplink['beforeText'] ?><a <?php echo $_toplink['aParams'] ?>><?php echo $_toplink['innerText'] ?></a><?php echo $_toplink['afterText'] ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
best practice is use xml for custom modifications. but in this case you need to add on links. try to edit top.links.phtml..you can call class using this
<action method="addLink" translate="label title" module="customer">
<label>Logout</label>
<url helper="customer/getLogoutUrl"/>
<title>Log Out</title>
<prepare/>
<urlParams/>
<position>2</position>
<liParams></liParams>
<aParams>class="logout-link"</aParams>
<beforeText><![CDATA[<span>]]></beforeText>
<afterText><![CDATA[</span>]]></afterText>
</action>
Foolow this link:
http://www.ibeccreative.com/blog/151/Magento-Tutorial-How-to-Customize-the-Top-Links-Block/
and for some links as wishlist:
app/design/frontend/[[YOURTHEME]]/default/layout/wishlist.xml
Change:
<reference name="top.links">
<block type="wishlist/links" name="wishlist_link" />
<action method="addLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>
To:
<reference name="top.links">
<block type="wishlist/links" name="wishlist_link">
<action method="setBeforeText">
<beforeText><![CDATA[<i class="fa fa-gift"></i>]]> </beforeText>
</action>
</block>
<action method="addLinkBlock">
<blockName>wishlist_link</blockName>
</action>
</reference>

Magento : add script phtml to product page

I have a phtml script that I want to add it to the product page view right under the price-box div or the content this img describe where I want to add it in the page source :
I have tried this :
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<catalog_product_view>
<reference name="product.info">
<block type="core/template" name="customprice" as="other" template="customprice/extJs.phtml"/>
</reference>
</catalog_product_view>
</layout>
but nothing is done! Can you explain why and how to fix it?
In your app/design/frontend/base/default/template/catalog/product/view.phtml file
Change the name from "other" to "otherjs" in your xml
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<h2><?php echo $this->__('Quick Overview') ?></h2>
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
<div><?php echo $this->getChildHtml('otherjs');//changes here?></div>
</div>
<?php endif;?>

Nested block within a reference not rendering when using ->getChildHtml()

this is my layout xml:
<catalog_category_default translate="label">
<label>Catalog Category (Non-Anchor)</label>
<reference name="content">
<block type="core/template" name="page.brand" template="page/brand.phtml" />
<block type="catalog/product_list" template="page/accessories.phtml">
<block type="catalog/navigation" name="catalog.leftnav" as="filter_menu" template="catalog/navigation/left.phtml"/>
</block>
</reference>
</catalog_category_default>
And from within page.accessories.phtml, inside some div block i call:
<?php echo $this->getChildHtml('filter_menu') ?>
but nothing renders out. Why is that?
this is code from the layered phtml file:
<div class="oh_shit"></div>
<?php if($this->canShowBlock()): ?>
<div class="block block-layered-nav">
<div class="block-title">
<strong><span><?php echo $this->__('Shop By') ?></span></strong>
</div>
<div class="block-content">
<?php echo $this->getStateHtml() ?>
<?php if ($this->getLayer()->getState()->getFilters()): ?>
<div class="actions"><?php echo $this->__('Clear All') ?></div>
<?php endif; ?>
<?php if($this->canShowOptions()): ?>
<p class="block-subtitle"><?php echo $this->__('Shopping Options') ?></p>
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php foreach ($_filters as $_filter): ?>
<?php if($_filter->getItemsCount()): ?>
<dt><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
<script type="text/javascript">decorateDataList('narrow-by-list')</script>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
Try adding your blocks in your layout xml to:
<catalog_category_layered translate="label">
<label>Catalog Category</label>
<reference name="content">
<block type="core/template" name="page.brand" template="page/brand.phtml" />
<block type="catalog/product_list" template="page/accessories.phtml">
<block type="catalog/navigation" name="catalog.leftnav" as="filter_menu" template="catalog/navigation/left.phtml"/>
</block>
</reference>
</catalog_category_layered>
ok. i got it. i accidentally deleted the name attribute on the block with type="product_list". when i re-added the name="product_list" it worked.

Resources