Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6889041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:06:20+00:00 2026-05-27T06:06:20+00:00

I have controller and it has following code: class Company_ModuleName_NameController extends Mage_Core_Controller_Front_Action { public

  • 0

I have controller and it has following code:

class Company_ModuleName_NameController extends Mage_Core_Controller_Front_Action
{

    public function indexAction()
    {
        $this->loadLayout();     
        $this->renderLayout();
    }
}

Then I have configured layout XML in my config.xml. Now I would like to add block that points to .phtml file and when user access my controller, that .phtml file would be shown to user.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:06:21+00:00Added an answer on May 27, 2026 at 6:06 am

    First of all you should define layout handle for your controller:

    Like this:

    <modulename_name_index>
    
    </modulename_name_index>
    

    The you should define where you want to display: content, left, right, another block:

    <modulename_name_index>
        <reference name="content">
        </reference name="content">
    </modulename_name_index>
    

    And then you define block which will be displayed:

    <modulename_name_index>
        <reference name="content">
            <block type="module/blockname" name="blockname" template="templatedir/templatefile.phtml"/>
        </reference name="content">
    </modulename_name_index>
    

    Where module/blockname is the name of your block. In the example file should be like this:

    Company/ModuleName/Block/Blockname.php.
    Your config.xml should be also definded properly so magento understood that with ‘module’ thing it should load particularly your class.
    Something like this:

    <global>
        ...
        <blocks>
            <module>
                <class>Company_Module_Block</class>
            </module>
        </blocks>
        ...
    </global>
    

    UPDATE 1

    If you want to simply render some content then you may use Magento’s default block class:

    core/template or Mage/Core/Block/Template
    

    This is how your xml file then will look like:

    <modulename_name_index>
        <reference name="content">
            <block type="core/template" name="blockname" template="templatedir/templatefile.phtml"/>
        </reference name="content">
    </modulename_name_index>
    

    BUT if you have in your .phtml file something like:

    $this->getSomethingSpecificValueForCurrentDisplay()
    

    This won’t work. On another side if you have very easy php in your phtml, like below, you don’t need your custom block.

    <?php for(i = 0; i++; i< 10){ ?>
         <?php echo "Hello mates" ?>
    <?php } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following controller file: <?php class Test extends CI_Controller { function __construct()
Inside my controller's action I have the following code: public ActionResult GridAction(string id) {
I'm using Play Framework, and have the following code: import org.hibernate.exception.ConstraintViolationException; ... public class
I have a controller/model hypothetically named Pets. Pets has the following declarations: belongs_to :owner
I have the following route: {language}/{controller}.mvc/{action}/{id} Once a user has choosen the language it
I have a controller which has a method called history class UsersController < ApplicationController
I have a view controller class that has to implement several protocols. Too keep
I have the problem that my view controller class has too many delegates and
I have this piece of code from GWT in Action: public void processOperator(final AbstractOperator
I have a controller in C# using the ASP.Net MVC framework public class HomeController:Controller{

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.