1

Where do I put the phtml file that all of this works with?

Current Files and their folder structure: app/code/local/Sean/Customform/controllers/IndexController.php

<?php
class Sean_Customform_IndexController extends Mage_Core_Controller_Front_Action{
    public function indexAction(){ //this will display the form
        $this->loadLayout();
        $this->_initLayoutMessages('core/session'); //this will allow flash messages
        $this->renderLayout();
    }
    public function sendAction(){ //handles the form submit
        $customer = Mage::getSingleton('customer/session')->getCustomer();
        $post = Mage::app()->getRequest()->getParams();

        $customer->setData('vendorMarkup', $post['vendorMarkup']);
        $customer->setData('vendorGramPrice', $post['vendorGramPrice']);
        $customer->setData('vendorGramFront', $post['vendorGramFront']);
        $customer->setData('vendorGramBack', $post['vendorGramBack']);
        $customer->setData('vendorDefaultCalc', $post['defaultMarkup']);
        $customer->save();

        Mage::getSingleton('core/session')->addSuccess($this->__('Your Calculator Preferences Are Updated!'));//add success message.
        $this->_redirect('*/*');
    }
}

app/code/local/Sean/Customform/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Sean_Customform>
            <version>0.0.1</version>
        </Sean_Customform>
    </modules>
    <global>
        <blocks>
            <customform><!-- block alias -->
                <class>Sean_Customform_Block</class>
            </customform>
        </blocks>
        <helpers>
            <customform><!-- helper alias -->
                <class>Sean_Customform_Helper</class>
            </customform>
        </helpers>
    </global>
    <frontend>
        <routers>
            <customform>
                <use>standard</use>
                <args>
                    <module>Sean_Customform</module>
                    <frontName>customform</frontName><!-- url key for module -->
                </args>
            </customform>
        </routers>
        <layout>
            <updates>
                <sean_customform>
                    <file>sean_customform.xml</file><!-- frontend layout file -->
                </sean_customform>
            </updates>
        </layout>
        <translate>
            <modules>
                <Sean_Customform>
                    <files>
                        <default>Sean_Customform.csv</default><!-- translation file (not mandatory) -->
                    </files>
                </Sean_Customform>
            </modules>
        </translate>
    </frontend>
</config>

app/code/local/Sean/Customform/helper.Data.php

<?php
class Sean_Customform_Helper_Data extends Mage_Core_Helper_Abstract{
}

And of course, app/etc/modules/Sean_Customform.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Sean_Customform>
            <active>true</active>
            <codePool>local</codePool>
        </Sean_Customform>
    </modules>
</config>
7
  • Please enable the template path hints to check from which path template is showing.
    – rajat kara
    Nov 3, 2016 at 13:28
  • I enabled them. Nov 3, 2016 at 13:31
  • The path template is: frontend/base/default/template/sean_customform/form.phtml Nov 3, 2016 at 13:32
  • All I want to know is what creates that path, and where is it specified? Nov 3, 2016 at 13:32
  • <layout> <updates> <sean_customform> <file>sean_customform.xml</file><!-- frontend layout file --> </sean_customform> </updates> </layout>
    – rajat kara
    Nov 3, 2016 at 13:51

3 Answers 3

1

In your config.xml file, you have this part.

    <layout>
        <updates>
            <sean_customform>
                <file>sean_customform.xml</file><!-- frontend layout file -->
            </sean_customform>
        </updates>
    </layout>

This defines a frontend layout xml file sean_customform.xml which is going to hold all frontend layout definition specifically for your module. You can find this file at location app/design/frontend/base/default/sean_customform.xml.

Here you will find your form.phtml file inclusion.

So basically you have a dedicated layout xml for your module and all module related layout definition is going to happen in that layout xml file (in this case, it is sean_customform.xml). This file will hold all phtml files.

12
  • Could I name the phtml file anything I want? As long as its in app/design/frontend/base/default/template/sean_customform? Nov 3, 2016 at 13:36
  • Yes you can give any name for your phtml file. But that name change you need to specify in app/design/frontend/base/default/sean_customform.xml too. Nov 3, 2016 at 13:37
  • I guess why I'm confused is I dont have a sean_customform.xml file Nov 3, 2016 at 13:39
  • you have. You may have that in your current package/theme location. normally an external extension holds that file in base/default theme location. search for sean_customform.xml file system wide. you can locate it. Nov 3, 2016 at 13:41
  • if you dont have that file, then you need to create that file Nov 3, 2016 at 13:42
0

You are basically asking us to explain how the layout system works. Once you understand how the xml layout works, you will answer your question.

Explaining the layout system here, now, would just take a bit much. your friend mr google will reveal lots of good resources in this regard.

One such resource is : http://magebase.com/magento-tutorials/demystifying-magentos-layout-xml-part-1/

Once you grep the layout system, your ability to change magento to your needs will jump ten fold. You will understand how to manipulate the display layer and adjust the sites visual display in areas without the need to rewrite core blocks.

Using layout directives to change display layer will help later with upgradability.

To many times i have come accross rewrite directives that gets placed on core blocks, which could very easily just be done using layout directives.

0

As per magento functionality when you define phtm file in your xml, Magento first search it in your current theme.

if file does not exist in current theme template path then it will searching in base theme.

You have to just define phtml file with template file path not full path of phtml file.

8
  • Everything works already. My question is how is the current file path working when I never specified it anywhere? Nov 3, 2016 at 13:15
  • Not getting your point. Nov 3, 2016 at 13:16
  • Any changes I make to app/code/design/frontend/base/default/template/sean_customform/form.phtml are visible when I visit www.website.com/customform Nov 3, 2016 at 13:19
  • I'm asking how does it know to look there when I never specified that file path? Nov 3, 2016 at 13:20
  • To clarify what determines where the form.phtml file is? Nov 3, 2016 at 13:21

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.