1

i want to put Send Email link in left side of the page. when i press on it, it should be linked with email.phtml page.

i tried 2 or 3 different ways but it not works.

i put below code in mytheme/layout/xyz.xml

<reference name="left">
     <block type="page/template_links" name="policy_contents" as="policy_contents"      template="page/template/links.phtml">
        <action method="addLink" translate="label title">
        <label>Our Commitment To Privacy</label>
        <url>#commitment</url>
        <title>Jump To This Section</title>
        </action>
    </block>
</reference>

above code works mean through which links display. but when i replace block type, template

and other detail which is related mydata it not works.

so, what should i put exact inside .php and .phtml file???

Thanks..

0

2 Answers 2

2

1)app\code\local\xyz\Example\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Xyz_Example>
            <version>0.1.0</version>
        </Xyz_Example>
    </modules>

<!-- ... -->
    <frontend>
        <routers>
            <!-- the <example> tagname appears to be arbitrary, but by
            convention is should match the frontName tag below-->
            <example>
                <use>standard</use>
                <args>
                    <module>Xyz_Example</module>
                    <frontName>example</frontName>
                </args>
            </example>
        </routers>
         <layout>
            <updates>
                <example module="example">
                    <file>xyz_example.xml</file>
                </example>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <example>
                <class>Xyz_Example_Block</class>  <!-- Path of the
 Block Folder, where all php files are located related to view -->
            </example>
        </blocks>
    </global>
</config>

2)app\design\frontend\default\example_theme\layout\xyz_example.xml

<?xml version="1.0" encoding="UTF-8"?>

<layout version="0.1.0">
    <default>
        <reference name="left">
        <block type="example/email" name="Email" as="Email" template="example/email/email.phtml">
        </block>
        </reference> 
    </default>

    <example_index_index>
    <reference name="content">
        <block type="example/example" template="example/email1.phtml"/>
    </reference>
    </example_index_index>
</layout>

3)app\design\frontend\default\example_theme\template\example\email\email.phtml

<a href="<?php echo $this->getBaseUrl().'example/index/';?>">Send Email</a>

4)app\code\local\Xyz\Example\controllers\IndexController.php

<?php
class Xyz_Example_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}
?>
1

What i understand from question is that you have placed the link but you are not getting how to create a url and render your phtml file on that url.

First of all you need to clear scope of the work according to which you should make a custom module which will provide you the url . Now this url you should use as the link. In your module create a controller and put all your functionality part in it's actions. Use phtml file after it just to create a view for website user.

You should check how to create custom module in magento. That will definitely help you.

Let me know here if you still can't figure out this. I will give you detailed information and code for this.

2
  • ya you getting exactly what i want.
    – MageDev
    Commented Jun 28, 2013 at 8:18
  • i know how to create module but problem is that i don't know what should i put in block/*.php and template/*.phtml, as i already created view and controller but i don't know which action need to put inside controller.. Please can you give me demo code???
    – MageDev
    Commented Jun 28, 2013 at 8:23

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.