0

My custom controller is loaded.

I want my phtml file to called from the layout.

I have tried as below:

\app\etc\modules\Mymodule_Customerpage.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
 <modules>
        <Mymodule_Customerpage>
               <active>true</active>
               <codePool>community</codePool>
        </Mymodule_Customerpage>
 </modules>
</config>

\app\code\community\Mymodule\Customerpage\etc\config.xml

<?xml version="1.0" encoding="UTF-8"?>
 <config>
<modules>
    <Mymodule_Customerpage>
        <version>1.0.0</version>
    </Mymodule_Customerpage>
</modules>
<frontend>
    <layout>
        <updates>
            <mymodule_customerpage module="Mymodule_Customerpage">
                <file>mymodule_customerpage.xml</file>
            </mymodule_customerpage>
        </updates>
    </layout>    
    <routers>
        <mymodule_customerpage>
            <use>standard</use>
            <args>
                <module>Mymodule_Customerpage</module>
                <frontName>mymodule_customerpage</frontName>
            </args>
        </mymodule_customerpage>
    </routers>        
</frontend>

<global>
    <helpers>
        <mymodule_customerpage>
            <class>Mymodule_Customerpage_Helper</class>
        </mymodule_customerpage>
    </helpers>        
</global>

</config>

\app\design\frontend\base\default\template\mymodule_customerpage.phtml

<layout>
<customer_account>
    <reference name="customer_account_navigation">
        <action method="addLink">
            <name>my_module_section</name>
            <path>mymodule_customerpage/index/index</path>
            <label>My Module Link</label>
        </action>
    </reference>
</customer_account>

<mymodule_customerpage_index_index>
    <update handle="customer_account" />
    <reference name="my.account.wrapper">
        <block type="core/template" name="mymodule_customerpage_content" template="mymodule_customerpage.phtml"/>            
    </reference>
</mymodule_customerpage_index_index>

<!--  <mymodule_customerpage_recipecreation_index>
    <reference name="content">
        <block type="customerpage/customerpage" name="rec_creation" template="addrecipe/createrecipe.phtml"/>            
    </reference>
</mymodule_customerpage_recipecreation_index>  -->


<mymodule_customerpage_recipeCreation_index>
    <reference name="content">
        <block type="core/template" name="rec_creation" template="addrecipe/createrecipe.phtml"/>            
    </reference>
</mymodule_customerpage_recipeCreation_index> 


<!-- <default>
    <reference name="rec_creation_page">
        <block type="core/template" name="rec_creation" template="createrecipe.phtml"/>
    </reference>
</default> -->

</layout>

app\design\frontend\base\default\template\mymodule_customerpage.phtml

<?php
<div class="dashboard">
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <div class="box-account box-info">
        <div class="box-head">
            <h2><?php echo $this->__('Manage My Recipes') ?></h2>
        </div>
    </div>
</div>

<div class="page-title">
    <form action="<?php echo $this->getUrl('mymodule_customerpage/recipeCreation/index') ?>" method="post" id="form-validate" autocomplete="off">
        <button type="submit" class="button" title="<?php echo $this->__('Add New Recipe') ?>">
            <span><span><?php echo $this->__('Add New Recipe') ?></span></span>
        </button>
    </form>
</div>

enter image description here

app\code\community\Mymodule\Customerpage\controllers\RecipeCreationController.php

class Mymodule_Customerpage_RecipeCreationController extends Mage_Core_Controller_Front_Action {
public function preDispatch()
{
    parent::preDispatch();
    $action = $this->getRequest()->getActionName();
    $loginUrl = Mage::helper('customer')->getLoginUrl();

    if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
        $this->setFlag('', self::FLAG_NO_DISPATCH, true);
    }
}      
public function indexAction()
{
    echo 'rec cre controller';
    $this->loadLayout();
    $this->renderLayout();
}
}

here when i click on Add new recipe button...

My controller mymodule_customerpage/recipeCreation/index/ is loading with blank page, which should call my phtml

Have placed phtml both in these locations and tried:

\app\design\frontend\default\default\template\addrecipe\createrecipe.phtml

\app\design\frontend\base\default\template\addrecipe\createrecipe.phtml

<?php
<div>
    <?php echo 'Create'; ?>
</div>
  • I tried <block type="mymodule_customerpage/recipeCreation_index" but i get blank page, phtml not calling – Sushivam Nov 4 '16 at 7:45
  • Block file call or not ? – Suresh Chikani Nov 4 '16 at 8:11
  • Im not using any Block class @SH Patel, i just have a controller , layout which should call my phtml – Sushivam Nov 4 '16 at 8:13
  • Then why you have mention in layout file. – Suresh Chikani Nov 4 '16 at 8:20
  • Add your completed module code. – Suresh Chikani Nov 4 '16 at 8:36
1

You have just little bit Case Sensitive mistake in you code

mymodule_customerpage_recipeCreation_index

To

mymodule_customerpage_recipecreation_index

Replace below code to in your layout file mymodule_customerpage.xml

<layout>
<mymodule_customerpage_recipecreation_index>
    <reference name="content">
        <block type="core/template" name="rec_creation" template="createrecipe.phtml"/>            
    </reference>
</mymodule_customerpage_recipecreation_index> 
</layout>
  • I still blank page here : mymodule_customerpage/recipeCreation/index/ with the above code..also tried moving the phtml inside a folder – Sushivam Nov 4 '16 at 8:29
  • first check in controller, controller call or not . – Suresh Chikani Nov 4 '16 at 8:31
  • yes its calling indexAction() in my controler – Sushivam Nov 4 '16 at 8:33
  • its was case error in recipecreation ...thanks – Sushivam Nov 4 '16 at 11:44
0

Try this,

Instead of this <reference name="rec_creation_page"> you try this <reference name="content">

<block type="customerpage/customerpage" name="rec_creation" template="createrecipe.phtml"/> change this also

<block type="customerpage/customerpage" name="rec_creation" template="foldername/createrecipe.phtml"/> 
  • have updated with content...still i get blank page in the controller path : mymodule_customerpage/recipeCreation/index – Sushivam Nov 4 '16 at 8:07
  • add your full folder path createrecipe.phtml – Magento 2 Nov 4 '16 at 8:08
  • template="folderpath/createrecipe.phtml" – Magento 2 Nov 4 '16 at 8:08
  • i have createrecipe phtml just inside the template folder – Sushivam Nov 4 '16 at 8:09
  • <block type="customerpage/customerpage" name="rec_creation" template="createrecipe.phtml"/> here you need to add path/filename.phtml template = " foldernam/filename.phtml" – Magento 2 Nov 4 '16 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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