Remove canonical link in Magento 1.9.3.x - magento

I want to remove the canonical link from a html page (Site Map).
<link rel="canonical" href="https://www.example.com/seositemap">
I used the following code in a layout and it does not work
<?xml version="1.0"?>
<layout version="0.1.0">
<seositemap_index_index>
<reference name="content">
<block type="seositemap/map" name="map" template="seositemap/map.phtml"/>
</reference>
<reference name="head">
<action method="removeItem"><type>link_rel</type><rel>canonical</rel></action>
</reference>
</seositemap_index_index>
</layout>
Any idea ?

here is how the method looks like
public function removeItem($type, $name)
{
unset($this->_data['items'][$type.'/'.$name]);
return $this;
}
there is no rel parameter. You should use "name" instead. And its content has to be the href of current link

Related

Nested block and getChildHtml() in magento

I have some trouble when i get data with function getChildHtml() .
Here is my layout.xml file
<?xml version="1.0"?>
<layout version="0.1.0">
<hello_index_index>
<reference name="content">
<block type="hello/hello" name="title" template="hello/title.phtml">
<block type="hello/hello" name="title1" template="hello/title1.phtml">
<block type="hello/hello" name="title2" template="hello/title2.phtml"/>
</block>
</block>
</reference>
</hello_index_index>
</layout>
when i try print data in file title2.phtml to the screen with code is
echo $this->getChildHtml('title2');
OR
echo $this->getChildHtml('title1');
In the first way is no data displayed on the screen .
In the second way have data displayed on the screen but only data in file title1.phtml .
So how to display the data in file title2.phtml
Thank everybody .
As your code example is somewhat obscured, it's difficult for me to understand what your blocks actually are and/or do.
Remove the association between "title1" and "title2", then try rendering your block(s) with getChildHtml again.
<?xml version="1.0"?>
<layout version="0.1.0">
<hello_index_index>
<reference name="content">
<block name="title" template="hello/title.phtml" type="hello/hello">
<block name="title1" template="hello/title1.phtml" type="hello/hello" />
<block name="title2" template="hello/title2.phtml" type="hello/hello" />
</block>
</reference>
</hello_index_index>
</layout>
<block type="hello/hello" name="title" template="hello/title.phtml">
<block type="hello/hello" name="title1" template="hello/title1.phtml">
<block type="hello/hello" name="title2" template="hello/title2.phtml"/>
</block>
</block>
in title.phtml write $this->getChildHtml('title1'); and in title1.phtml write
$this->getChildHtml('title2')
because magento blocks can render only "child" blocks when using "getChildHtml()"

Magento, Static Block won't render?

this is my local.xml
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<block type="core/text_list" name="banner" as="banner" translate="label">
<label>Banner Area</label>
</block>
</reference>
<reference name="bannerblock">
<block type="core/template" name="bannerblock" template="banner.phtml" />
</reference>
</default>
</layout>
this is my 1column.phtml
<?php echo $this->getChildHtml('banner') ?>
I am not sure why it is not rendered. I think it might have to do with the placement of banner.phtml
should I put in
app/design/frontend/x/x/template/
or inside
app/design/frontend/x/x/template/page/html/
how do magenta find out?
You are referencing "bannerblock" block from inside of "bannerblock". Try moving the "bannerblock" block delaration into the "root" reference node:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="root">
<block type="core/text_list" name="banner" as="banner" translate="label">
<label>Banner Area</label>
</block>
<block type="core/template" name="bannerblock" template="banner.phtml" />
</reference>
</default>
</layout>

magento - adding a block using local.xml

if I have a template in
app\design\frontend\base\default\template\dir\template.phtml
that look like this
<div class='block block-list'>
<div class='block-title'><strong><span>Some Block</span></strong></div>
<div class='block-content'>
<?php echo "my content"; ?>
</div>
</div>
How can I show it on a catalog page using local.xml? Shouldn't this code work?
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="right">
<block type="core/template"
name="somename"
template="dir/template.phtml" />
</reference>
</default>
</layout>
I think you can not have custom layout handle<catalog_category_default translate="label"> inside default layout handle<default>
Correct me if I am wrong.
You have to use template reference name before that reference tag.
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<catalog_category_default translate="label">
<reference name="right">
<block type="core/template"
name="somename"
template="dir/template.phtml" />
</reference>
</catalog_category_default>
</default>
</layout>

magento: get variable from block or hlper into javascript file

I am including a js file via the layout xml:
for example:
<reference name="head">
<action method="addItem">
<type>js</type>
<name>myjs.js</name>
</action>
</reference>
This is fine. But, i am setting up an ajax call inside myjs.js and would like to pull the post url from a helper class.
How would this be possible?
Inside your reference to the head I would add a block which would output a partial that sets a js var ahead of the myjs.js file being added.
For instance:
<reference name="head">
<block type="page/html" name="mycustomblock" template="page/html/mycustomblock.phtml"/>
<action method="addItem">
<type>js</type>
<name>myjs.js</name>
</action>
</reference>
And your file mycustomblock.phtml would contain:
<?php
// below is javascript that is being populated by your helper
?>
<script> var myblogpost = <?php echo Mage::helper('mycustom/helper')->blogPostUrl();?>; </script>

Understanding Magento Adminhtml Layouts

I am trying to load a custom layout page for my custom admin page "devices". Its not working ! :)
<layout version="0.1.0">
<adminhtml_devices_index_index>
<reference name="content">
<block type="adminhtml/template" name="index" output="toHtml" template="devices/index.phtml"/>
</reference>
</adminhtml_devices_index_index>
</layout>
If this is the XML in my app/design/adminhtml/default/default/layout/devices.xml
What are the different files/attributes I must be aware of ?
Also, what does type='adminhtml/template' actually point to ?
Note: My Controller code is
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
For a quick test, use a non-template block. The block is going to be output as a course of rendering in the "content" block, so no need to specify output="toHtml".
<reference name="content">
<block type="core/text" name="devices.test">
<action method="setText">
<val>This is some sample text</val>
</action>
</block>
</reference>
The block type argument adminhtml/template points to the block class group "adminhtml", which is defined in Mage_Adminhtml config.xml:
<global>
<blocks>
<adminhtml>
<class>Mage_Adminhtml_Block
Based on this, the adminhtml/template argument points to the block name Mage_Adminhtml_Block_Template.
Try it:
<layout version="0.1.0">
<devices_adminhtml_index_index>
<reference name="content">
<block type="adminhtml/template" name="index" output="toHtml" template="devices/index.phtml"/>
</reference>
</devices_adminhtml_index_index>
</layout>
And I not sure what here should be: adminhtml/template Try replace it with core/template

Resources