I'm trying to create a new page to my module without success. I have created a module with the contents:
app\code\local\CompanyName\Insignias\etc\config.xml
<config>
<modules>
<CompanyName_Insignias>
<version>0.0.1</version>
</CompanyName_Insignias>
</modules>
<frontend>
<routers>
<insignias>
<use>standard</use>
<args>
<module>CompanyName_Insignias</module>
<frontName>insignias</frontName>
</args>
</insignias>
</routers>
<layout>
<updates>
<insignias>
<file>insignias.xml</file>
</insignias>
</updates>
</layout>
</frontend>
<...>
</config>
app\code\local\CompanyName\Insignias\controllers\IndexController.php
<?php
class CompanyName_Insignias_IndexController extends Mage_Core_Controller_Front_Action {
public function indexAction() {
$this->loadLayout();
$this->renderLayout();
}
}
and
app/design/frontend/base/default/layout/insignias.xml
<?xml version="1.0"?>
<layout>
<insignias_index_index>
<reference name="content">
<block type="insignias/index" name="insignias_index" template="insignias/index.phtml" />
</reference>
</insignias_index_index>
</layout>
I have created the index.phtml file at app/design/frontend/base/default/template/insignias/index.phtml with a <?php echo "worked" ?> to test it, but when I try to access domain/index.php/insignias it shows me all the default magento blocks and a blank page in the middle where my echo should appear.
Can someone help me?
edit:
Here is a picture of my screen
There's anything in the log files?
--
Btw...
You need to call your block in the indexController.php before renderLayout()
The call would look something like
$myBlock = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'newpage', array('template' => 'newpage/content.phtml'));
$this->getLayout()->getBlock('content')->append($myBlock);
--
You can find Magento log in /var/log within your root Magento installation
There will usually be two files by default, exception.log and system.log.
app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml
app/etc/modules/AMA_Checkout.xml
<?xml version="1.0"?>
<config>
<modules>
<AMA_Checkout>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Checkout />
</depends>
</AMA_Checkout>
</modules>
</config>
app/code/local/AMA/Checkout/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<AMA_Checkout>
<version>1.0.0</version>
</AMA_Checkout>
</modules>
<global>
<blocks>
<amacheckout>
<class>AMA_Checkout_Block</class>
</amacheckout>
</blocks>
</global>
</config>
app/code/local/AMA/Checkout/Block/Onepage/Shipping/Method/Available.php
<?php
class AMA_Checkout_Block_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available
{
public function _construct()
{
parent::_construct();
$this->setTemplate('amacheckout/checkout/onepage/shipping_method/available.phtml');
}
}
template:
app/design/frontend/default/base/template/amacheckout/checkout/onepage/shipping_method/available.phtml
Related
I'm writing a module for magento 1.9. Help please set the attributes for the
app/design/frontend/rwd/default/layout/kalinin_form.xml:
<?xml version="1.0" ?>
<layout>
<kalininform_index_index>
<reference name="content">
<block type="kalininform/form" template="Kalinin_Form/index.phtml" />
</reference>
</kalininform_index_index>
</layout>
I now have the type attribute set to false.
The problem is that the browser displays a blank page with the content area on localhost/magento3/index.php/form
Here is the rest of the code of the module.
app/design/frontend/rwd/default/template/Kalinin_Form/index.phtml:
<?php
echo('qqqqqqqqqqqqq');
app/code/local/Kalinin/Form/controllers/IndexController.php:
<?php
class Kalinin_Form_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
app/code/local/Kalinin/Form/Block/Form.php:
<?php
class Kalinin_Form_Block_Form extends Mage_Core_Block_Template
{
public function getNewsCollection()
{
Mage::log("Your Log Message");
return true;
}
}
app/code/local/Kalinin/Form/etc/config.xml:
<?xml version="1.0" ?>
<config>
<modules>
<Kalinin_Form>
<version>0.0.1</version>
</Kalinin_Form>
</modules>
<frontend>
<layout>
<updates>
<kalininform>
<file>kalinin_form.xml</file>
</kalininform>
</updates>
</layout>
<routers>
<kalininform>
<use>standard</use>
<args>
<module>Kalinin_Form</module>
<frontName>form</frontName>
</args>
</kalininform>
</routers>
</frontend>
<global>
<blocks>
<Kalinin_Form>
<class>Kalinin_Form_Block</class>
</Kalinin_Form>
</blocks>
</global>
</config>
In general, I have a problem with understanding the attributes into app/design/frontend/rwd/default/layout/kalinin_form.xml
Official documentation is not present. I would be grateful if you explain what's what.
In your app/design/frontend/rwd/default/layout/kalinin_form.xml file, your block attribute type value is wrong. it should be kalinin_form/form.
<?xml version="1.0" ?>
<layout>
<kalininform_index_index>
<reference name="content">
<block type="kalinin_form/form" template="Kalinin_Form/index.phtml" />
</reference>
</kalininform_index_index>
</layout>
Value of type attribute should be matched with blockgroup_name given in config.xml.
Please see, your block group name is Kalinin_Form
<global>
<blocks>
<Kalinin_Form>
<class>Kalinin_Form_Block</class>
</Kalinin_Form>
</blocks>
</global>
I am trying to load template file from layout in my module but my layout xml file is not adding in config.xml .I tried number of solution but I don't know what mistake I am doing.Please help me and tell me where I am wrong.I added my code below..
IndexController.php
<?php
class Magemodul_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Magemodul_Test>
<version>1.0.0</version>
</Magemodul_Test>
</modules>
<frontend>
<routers>
<magemodultest>
<use>standard</use>
<args>
<module>Magemodul_Test</module>
<frontName>test</frontName>
</args>
</magemodultest>
</routers>
<layout>
<updates>
<magemodultest>
<file>test.xml</file>
</magemodultest>
</updates>
</layout>
</frontend>
<global>
<blocks>
<test>
<class>Magemodul_Test_Block</class>
</test>
</blocks>
</global>
</config>
block file Monblock.php
<?php
class Magemodul_Test_Block_Monblock extends Mage_Core_Block_Template
{
public function methodblock()
{
return 'informations about my block !!' ;
}
}
layout xml file test.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<test_index_index>
<reference name="content">
<block type="test/monblock" name="afficher_monbloc" template="test/afficher.phtml">
</reference>
</test_index_index>
</layout>
template file afficher.phtml
<?php
echo $this->getmethodblock();
?>
I have a problem. I following guideline but it doesn't work. I don't know debug how. Please tell me the way resolve problem.
This is HS_Imagepro.xml in etc/modules/ folder
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<active>True</active>
<codePool>core</codePool>
</HS_Imagepro>
</modules>
</config>
This is config.xml in HS/Imagepro/etc folder
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<version>0.1.1</version>
</HS_Imagepro>
</modules>
<admin>
<routers>
<adminhtml>
<use>admin</use>
<args>
<modules>
<module>HS_Imagepro</module>
<frontName>imagepro</frontName>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<adminhtml>
<menu>
<imagepro_menu translate="title" module="imagepro">
<title>ImagePro</title>
<sort_order>9999</sort_order>
<children>
<first_page module="imagepro">
<title>Our First Page</title>
<action>imagepro/index/index</action>
</first_page>
</children>
</imagepro_menu>
</menu>
</adminhtml>
<global>
<helpers>
<imagepro>
<class>HS_Imagepro_Helper</class>
</imagepro>
</helpers>
</global>
</config>
This is IndexController.php in HS/Imagepro/controllers/
<?php
class HS_Imagepro_IndexController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
The result is the page not found.
If The following right guideline, access link http://localhost/magento/index.php/imagepro/ will appear admin login screen.
In ,HS_Imagepro.xml file the test TRUE Should be true.
routing code Wrong in config.xml
<?xml version="1.0"?>
<config>
<modules>
<HS_Imagepro>
<version>0.1.1</version>
</HS_Imagepro>
</modules>
<admin>
<routers>
<!-- Includes our controller, so when we add the adminhtml menu item below, it is found! -->
<adminhtml>
<args>
<modules>
<imagepro before="Mage_Adminhtml">HS_Imagepro_Adminhtml</imagepro>
</modules>
</args>
</adminhtml>
</routers>
</admin>
</config>
Also controller file and path name is wrong
HS/Imagepro/controllers/Adminhtml/ImageproController.php
<?php
class HS_Imagepro_Adminhtml_ImageproController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
?>
Testing url yourhost/magento/index.php/admin/imagepro
More details on http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table#directory_additions
and frontend module http://www.amitbera.com/create-an-magento-extension-with-custom-database-table/
This is my activation file,
in app/etc/modules/My_Test.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<My_Test>
<active>true</active>
<codePool>local</codePool>
</My_Test>
</modules>
</config>
This is my config file in app/code/local/MY/Test/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<global>
<helpers>
<my_test>
<class>My_Test_Helper</class>
</my_test>
</helpers>
<models>
<mytest>
<class>My_Test_Model</class>
</my_test>
</models>
<blocks>
<my_test>
<class>My_Test_Block</class>
</my_test>
</blocks>
</global>
<frontend>
<routers>
<my_test>
<use>standard</use>
<args>
<module>My_Test</module>
<frontName>test</frontName>
</args>
</my_test>
</routers>
</frontend>
</config>
This is my controllers code
in app/core/local/My/Test/controllers/IndexController.php
<?php
class My_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo "This is the Module MyTest";
}
}
Now when i am giving the url
176.58.99.99/herbal/index.php/test/index/index
176.58.99.99/herbal/index.php/test/
176.58.99.99/herbal/test/index/index
176.58.99.99/herbal/test/
Its showing 404 error
You say your controller is located in app/core/local/My/Test/controllers/IndexController.php while it should be placed as followed: app/code/local/My/Test/controllers/IndexController.php
I had the same problem, but in my case it was about file permissions. Make sure that your files and directories have the proper access permissions, if not, magento will never be able to read those files.
I'm new in Magento and I'm trying to make a layout for a module I've build. I have a simple module and an IndexController which outputs 'Hello World.'(I've use this tutorial).
Now I want to make a layout for that module and I've used this tutorial but it doesn't work. Can someone point me to a tutorial or can explain me how layouts work in Magento?
Thx :)
Here's what I've done so far:
I have a package called 'Andrei' and a module 'Hello World'.
Here is the config.xml for my module:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Andrei_Helloworld>
<version>0.1.0</version>
</Andrei_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Andrei_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
</config>
Here is the Andrei_Helloworld module:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Andrei_Helloworld>
<active>true</active>
<codePool>local</codePool>
</Andrei_Helloworld>
</modules>
</config>
And here is my controller:
class Andrei_Helloworld_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
echo 'Hello world';
}
}
This is all I've done so far. The module works properly. And I want a layout for my IndexController. Thx :)
so, there is some stuff missing...
declare the layout update in the your config.xml:
<frontend>
...
<layout>
<updates>
<helloworld>
<file>helloworld.xml</file>
</helloworld>
</updates>
</layout>
...
</frontend>
create the layout xml file, in app/design/frontend/base/default/layout/helloworld.xml and in it you create a reference to your module/controller/action:
<?xml version="1.0"?>
<layout>
<helloworld_index_index>
<reference name="content">
<block type="core/template" name="helloworld" template="helloworld.phtml" />
</reference>
</helloworld_index_index>
</layout>
create the phtml file you've just set as template in your xml layout file, ie app/design/frontend/base/default/template/helloworld.phtml:
this is the content of helloworld.phtml
load and render all this stuff, in your controller's action, replace your echo statement with:
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
disable cache, refresh browser, sit back and enjoy