Magento Layout Updates not working - magento

I'm having a problem with a custom module. The layout update doesn't work.
Here is the module's config.xml file:
<?xml version="1.0"?>
<config>
<modules>
<Pesach_Categories>
<version>1.0.0</version>
</Pesach_Categories>
</modules>
<frontend>
<layout>
<updates>
<categories>
<file>footer.xml</file>
</categories>
</updates>
</layout>
</frontend>
</config>
Here is the code in the app/design/frontend/default/MyTheme/layout/footer.xml file:
<?xml version="1.0"?>
<layout version="0.0.1">
<default>
<reference name="footer">
<block type="catalog/navigation" name="catList" template="catalog/categories/cat.phtml"/>
</reference>
</default>
</layout>
And here is the code for app/design/frontend/default/MyTheme/template/catalog/categories/cat.phtml:
<?php foreach ($this->getStoreCategories() as $_category): ?>
<div class="Cen_Wrapper1">
<span class="BreadCrumbsred">
<?php echo $_category->getName(); ?></span><br/>
<?php $_children = $_category->getChildren(); ?>
<?php if($_children->count()) : ?>
<?php foreach($_children as $_child) : ?>
<?php echo $_child->getName(); ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php endforeach ?>
The layout updates seem to be coming in (they show up in CommerceBug page layout XML) but they don't seem to do anything.
Here is the following things that i checked:
The file permissions to the app/design/.../MyTheme/template is rwx r-x r-x
The file permissions to the app/design/.../base/default is rwx r-x r-x
The issue is not limited to the custom module...there is another module (FME_Shop_by_manufacturers) that tries to make layout updates to the head and it also doesn't work.

Try to put your phtml to base/default.
The thing is that you should your template in the same theme what is currently set for you shop. You can check your current theme in
System-Configuration-Design-Theme tab.
UPDATE 1
If module is enabled?
Check magento log file.
Try to install your module on clean magento installation. Perhaps core is corrupted.
Check if some modules doesn't overwrite catalog/navigation
Also try in this way:
<?xml version="1.0"?>
<layout version="0.0.1">
<default>
<reference name="footer">
<block type="catalog/navigation" name="catList" output="toHtml" template="catalog/categories/cat.phtml"/>
</reference>
</default>
</layout>
OR in footer.phtml insert
$this->getChildHtml('catList');

Related

Assign a custom popup.phtml file through a custom extension

Building a custom extension and need to load a new popup.phtml file so we can place our own code into it.
Ive already tried adding it as a package, but I want to avoid this so wondering if theres a way to add this/link to this using an xml layout file for example?
So in short, when a user clicks on the "Track Shipment" link in either the end user account, or the admin clicks the link from Sales > Shipments > View it will load my popup.phtml file and not the default one.
I've managed to solve this so here's how I managed to to it just in case it helps anyone else out :)
First of all in the app/etc/modules you'll need to create a file, lets call it Vendor_Module.xml and in there, we'll put the code;
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Vendor_Module>
<active>true</active>
<codePool>community</codePool>
</Vendor_Module>
</modules>
</config>
Then in app/community/Vendor/Module/etc/config.xml I added the following;
<?xml version="1.0"?>
<config>
<modules>
<Vendor_Module>
<version>1.0.0</version>
</Vendor_Module>
</modules>
<frontend>
<layout>
<updates>
<Vendor_Module_layout module="Vendor_Module">
<file>vendor_module.xml</file>
</Vendor_Module_layout>
</updates>
</layout>
</frontend>
</config>
In app/design/admin/default/default/layout I created vendor_module.xml and added the following code;
<?xml version="1.0"?>
<shipping_tracking_popup translate="label">
<label>Shipment Tracking Popup</label>
<reference name="root">
<action method="setTemplate"><template>page/popuper.phtml</template></action>
</reference>
<reference name="content">
<block type="shipping/tracking_popup" name="shipping.tracking.popup" template="shipping/tracking/popuper.phtml" />
</reference>
</shipping_tracking_popup>
In app/design/frontend/base/default/layout I created another vendor_module.xml file and added the code;
<?xml version="1.0"?>
<layout>
<shipping_tracking_popup>
<reference name="content">
<block type="shipping/tracking_popup" name="shipping.tracking.popup" template="Vendor/shipping/tracking/popup.phtml" />
</reference>
</shipping_tracking_popup>
</layout>
Finally, in app/design/frontend/base/default/template/Vendor/shipping/tracking I created a new file called popup.phtml and then added my own required code that I wanted displayed here. The following code is just example code that will add some text and a close button.
<div class="page-title title-buttons">
<h1><?php echo $this->__('Tracking Information'); ?></h1>
<button class="button" onclick="window.close(); window.opener.focus();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
</div>
<!-- Add Your Stuff Here -->
<div class="buttons-set">
<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Close Window')) ?>" class="button" onclick="window.close(); window.opener.focus();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
</div>
Thats it, hope it helps!

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;?>

Custom currency switcher in Magento header vanished?

I built a custom currency switcher for my header yesterday, all working well. Today I came to setup the catalog pages and found myself needing to remove the standard currency switcher in the left column, I opened up my local.xml and add a remove to currency. Silly choice perhaps, I managed after fiddleing to get the left.currency to be removed when i suddenly noticed something I had done in one of my files had stopped my header custom currency switcher from displaying.
local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<!-- Remove callouts and rarely used stuff -->
<remove name="right.poll"/>
<remove name="right.permanent.callout"/>
<remove name="left.permanent.callout"/>
<remove name="paypal.partner.right.logo"/>
<remove name="catalog.compare.list" />
<!-- add the local stylesheet -->
<reference name="head">
<action method="addCss"><stylesheet>css/smoothness/jquery-ui-1.10.1.custom.css</stylesheet></action>
<action method="addJs"><script>ahoy/jquery-1.9.1.js</script></action>
<action method="addJs"><script>ahoy/jquery-ui-1.10.1.custom.js</script></action>
<action method="addJs"><script>ahoy/script.js</script></action>
<action method="addCss"><stylesheet>css/1140.css</stylesheet></action>
<action method="addCss"><stylesheet>css/ahoy.css</stylesheet></action>
</reference>
<reference name="header">
<block type="template/currency" name="custom_currency_selector" template="currency/currency.phtml"/>
</reference>
</default>
<catalog_category_view>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
</catalog_category_view>
First part of header.phtml
<div class="header">
<div class="row">
<div class="row">
<div class="sixcol">
<?php echo $this->getChildHtml('topLinks') ?>
<?php echo $this->getChildHtml('custom_currency_selector') ?>
</div>
<div class="sixcol last">
<div class="row">
test/default/template/currency/currency.phtml
<?php if($this->getCurrencyCount() > 1): ?>
<div class="currency-block">
<ul>
<?php foreach ($this->getCurrencies() as $_code => $_name): ?>
<?php $active = ($_code==$this->getCurrentCurrencyCode()) ? "active":""; ?>
<li>
<a class="<?php echo $active; ?>" href="<?php echo $this->getSwitchCurrencyUrl() . "currency/" . $_code; ?>" title="Set <?php echo $_code; ?> as your chosen currency">
<?php echo Mage::app()->getLocale()->currency($_code)->getSymbol(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
From what I remember this is all I need to create the block, assign its position and call it out. I've been clearing the cache constantly while fiddeling, I reloaded in the currency conversion data, removed and retested the "remove" in local that removed the left bars currency, that one has now come back after i removed the remove for left.currency but the top one never came back.
These are my current files, so no removes at all for currency now, I'm not sure when this vanished but I've only been playing with the left sidebar stuff, after css struggles i tried to remove the currency and as i did not know how to reference it tried killing off all currency i could find and when i twigged i was no longer sure when i removed the top currency.
Try changing type="template/currency" to type="directory/currency"

Magento: Move product filters

As default, the available product filters are displayed in the left sidebar. But I'd like to display them above the product list instead.
I simply tried to just copy the following code from /template/catalog/layer/view.phtml to /template/catalog/product/list.phtml:
<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>
But apparently it doesn't work that way. How should I do?
Thank you in advance!
You need to make the block (a php class) which uses the filters template a child of the class where you wish to include those filters. This is done in layout XML.
In a local.xml file in your theme's layout folder, do the following:
<?xml version="1.0" ?>
<layout>
<catalog_category_layered>
<!-- remove from left block -->
<reference name="left">
<action method="unsetChild">
<child>catalog.leftnav</child>
</action>
</reference>
<!-- add as child to product list block -->
<reference name="product_list">
<action method="insert">
<child>catalog.leftnav</child>
</action>
</reference>
</catalog_category_layered>
</layout>
using the above, you can simply call <?php echo $this->getChildHtml('catalog.leftnav') ?> inside your custom list template for it to show. You can either style it using CSS, or you can change its template by adding this inside the catalog_category_layered node above:
<reference name="catalog.leftnav">
<action method="setTemplate">
<child>path/to/template.phtml</child>
</action>
</reference>

Exact Placement of childHtml Block (unexpected result)

I am trying to place a new phtml block at a specific place within another phtml page and I am not getting the results I expected - any advice would be much appreciated.
Specifically, I created a new childHtml block for the cart page in my module's xml layout file:
<layout version="0.1.0">
<checkout_cart_index>
<reference name="head">
<action method="addJs"><script>varien/product.js</script></action>
<action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
<action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
<action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
</reference>
<reference name="content">
<block type="delivery/frontend_checkout_cart_delivery" name="delivery.container" as="delivery" template="unleaded/delivery/checkout/cart/shipping/delivery.phtml"/>
<block type="core/html_calendar" name="delivery_html_calendar" as="delivery_html_calendar" template="page/js/calendar.phtml"/>
</reference>
</checkout_cart_index>
</layout>
Next I made a call to $this->getChildHtml('delivery') in my modified checkout/cart/shipping.phtml template where I wanted it placed:
....
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
....
<?php foreach ($_rates as $_rate): ?>
....
<li>
<?php if ($_rate->getCode() == 'delivery'): ?>
<?php echo $this->getChildHtml('delivery'); ?>
<?php endif; ?>
</li>
....
<?php endforeach; ?>
....
<?php endforeach; ?>
....
What I wanted / expected was to see my block output where I inserted it, but instead it is being output at the very bottom of the page (see screenshot). I am almost certain my mistake is an xml / layout based mistake, but I don't know what?
You call getChildHtml() from within the checkout.cart.shipping block, but add your new block to content. Instead of,
<reference name="content">
...you simply need to say which block your new one will be the child of.
<reference name="checkout.cart.shipping">

Resources