4

With the reference from my yesterday question CODE, now I am able to show the send mail to friend in a popup with the below code in test.phtml( set it via local.xml)

test.phtml

<?php if ($this->canEmailToFriend()): ?>
    <li><a href='#' onclick="return showCompare('<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>');" class="link-email-friend" title="<?php echo $this->__('Email to a Friend') ?>"><?php echo $this->__('Email to a Friend') ?></a></li>
<?php endif; ?>

JS code( test.phtml)

<script type="text/javascript">
    function showCompare(url){
    win = new Window({ title: "Compare Products", url:url, zIndex:3000, destroyOnClose: true, recenterAuto:false, resizable: false, width:450, height:473, minimizable: false, maximizable: false, draggable: false});
    win.showCenter(true);
    }
</script> 

Now the pop up is shown , but with whole page layout ie Header & Footer showing up, so I want here is to REMOVE the Header & Footer,

So After a careful inspection, I found out the particular block is residing in

frontend/base/default/layout/sendfriend.xml

So What I did here is created a local.xml file to override( Header & Footer), with the below code

<layout version="0.1.0">
    <sendfriend_product_send translate="label">
        <label>Catalog Product Email to a Friend</label>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </reference>
        <reference name="head">
            <action method="addJs"><script>varien/product.js</script></action>
        </reference>
        <reference name="root">
            <remove name="header"/>
            <remove name="footer"/>
        </reference>
        <reference name="content">
            <block type="sendfriend/send" name="sendfriend.send" template="sendfriend/send.phtml" />
        </reference>
    </sendfriend_product_send>
</layout>

But unfortunately its not working , but when I place the same piece of code in sendfriend.xml, it works (removing Header & Footer).

I am a bit lost, as how I am gonna put things up her, I mean how to do this in a standard way ?

5
  • 1
    where did you put the local.xml file? By the way, you can also use page/popup.phtml as root template which shows just the content without header and footer Commented Jul 2, 2015 at 7:42
  • @fschmengler in the same directory ie frontend/base/default/layout/ Commented Jul 2, 2015 at 8:41
  • That's the problem. You have to put it into the directory of the actual theme you use. local.xml files of parent themes are not taken into account. Commented Jul 2, 2015 at 8:43
  • ohh @fschmengler but sendfriend.xml is in frontend/base/default/layout/ directory Commented Jul 2, 2015 at 8:44
  • 1
    yes and that's fine as it is a theme independent layout file from a module. local changes belong to the theme Commented Jul 2, 2015 at 8:46

3 Answers 3

2

The local.xml file must be in the directory of the actual theme you are using, i.e.

app/design/frontend/[package]/[theme]/layout

Multiple local.xml files in the fallback hierarchy are not taken into account. The first of these that can be found, is used:

app/design/frontend/[package]/[theme]/layout/local.xml
app/design/frontend/[package]/default/layout/local.xml
app/design/frontend/base/default/layout/local.xml

(assuming default hierarchy and no custom defined hierarchy)

4
  • It worked, but am I doing the right thing? I mean actual file has <action method="addJs"><script>varien/product.js</script></action> but in my default layout(local.xml) i have just used <sendfriend_product_send translate="label"> <label>Catalog Product Email to a Friend</label> <reference name="root"> <remove name="header"/> <remove name="footer"/> </reference> </sendfriend_product_send> Commented Jul 2, 2015 at 8:52
  • Sounds right, you should only have modifications in local.xml, not repeat definitions that are already in the module's xml Commented Jul 2, 2015 at 8:57
  • I assume it will remove 'varien/product.js' which is present in main sendfriend.xml .. Commented Jul 2, 2015 at 8:59
  • check my answer that I posted please , give me a feedback Commented Jul 2, 2015 at 9:04
4

Try the below code. No need to add reference for remove block

<layout version="0.1.0">
    <sendfriend_product_send translate="label">
        ......
        <remove name="header"/>
        <remove name="footer"/>
        ......
    </sendfriend_product_send>
</layout>
0
1

A big thanks to @fshmengler for the quick solution ( it worked like an charm), later after a thoughtful thinking I just modified my local.xml

from

<sendfriend_product_send translate="label">
    <label>Catalog Product Email to a Friend</label>
    <reference name="root">
        <remove name="header"/>
        <remove name="footer"/>
    </reference>
</sendfriend_product_send>

to

<sendfriend_product_send translate="label">
     <reference name="root">
        <action method="setTemplate"><template>page/popup.phtml</template></action>
    </reference>
</sendfriend_product_send>

Hope this is a good solution compare to removing Head & Footer ?

2
  • 1
    This should be an addition to your question (too long for a comment), not an answer on its own. But yes, if you do not require the sidebar column, this is the best solution. Commented Jul 2, 2015 at 9:14
  • well I am Glad ! Thanks, let this solution be here it might be helpful for others.. :) Commented Jul 2, 2015 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.