app\code\local\Stw\Tree\Block\Adminhtml\Adminblock.php
<?php
class Stw_Tree_Block_Adminhtml_Adminblock extends Mage_Adminhtml_Block_Template
{
public function __construct()
{
parent::__construct();
}
protected function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getHandleUpdates()
{
Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
}
}
app\code\local\Stw\Tree\controllers\Adminhtml\CustomController.php
class Stw_Tree_Adminhtml_CustomController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
$this->loadLayout();
$this->_setActiveMenu('mycustomtab');
$this->renderLayout();
}
}
app\design\adminhtml\default\default\layout\tree.xml
<?xml version="1.0"?>
<layout>
<default>
<reference name="content">
<block type="tree/adminhtml_adminblock" name="tree" template="tree/myform.phtml" />
</reference>
</default>
</layout>
app\code\local\Stw\Tree\etc\config.xml
<?xml version="1.0"?>
<config>
<modules>
<Stw_Tree>
<version>1.0.0</version>
</Stw_Tree>
</modules>
<global>
<helpers>
<stw_tree>
<!-- Helper definition needed by Magento -->
<class>Mage_Core_Helper</class>
</stw_tree>
</helpers>
<blocks>
<stw_tree>
<class>Stw_Tree_Block</class>
</stw_tree>
</blocks>
</global>
<admin>
<routers>
<adminhtml>
<args>
<modules>
<stw_tree before="Mage_Adminhtml">Stw_Tree_Adminhtml</stw_tree>
</modules>
</args>
<layout>
<updates>
<tree>
<file>tree.xml</file>
</tree>
</updates>
</layout>
</adminhtml>
</routers>
</admin>
</config>
I want load myform.phtml in admin section of magento, but nothing is loading. I am not understanding what is wrong in that. please someone tell me changes. myform.phtml contains pure HTML code
As defined block in config.xml as below :-
<blocks>
<stw_tree>
<class>Stw_Tree_Block</class>
</stw_tree>
</blocks>
You need to use same alias to call this block from Layout as below :-
<layout>
<default>
<reference name="content">
<block type="stw_tree/adminhtml_adminblock" name="tree" template="tree/myform.phtml" />
</reference>
</default>
</layout>
I don't believe the layout node should be inside the router note like that in your config.xml file. You should add a new adminhtml node as a sibling to admin, i.e. a direct child of config.
</admin>
<adminhtml>
<layout>
<updates>
<tree>
<file>tree.xml</file>
</tree>
</updates>
</layout>
</adminhtml>
</config>
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();
?>
friends
i have created custom module ,in which i have crated blocks .i want use this block in template but this is not work.
This is my config file :-
<?xml version="1.0"?>
<config>
<modules>
<CustomModule_SocialLogin>
<version>1.0.0</version>
</CustomModule_SocialLogin>
</modules>
<frontend>
<routers>
<customer>
<args>
<modules>
<CustomModule_SocialLogin before="Mage_Customer">CustomModule_SocialLogin_Customer </CustomModule_SocialLogin>
</modules>
</args>
</customer>
<sociallogin>
<use>standard</use>
<args>
<module>CustomModule_SocialLogin</module>
<frontName>sociallogin</frontName>
</args>
</sociallogin>
</routers>
<layout>
<updates>
<CustomModule_SocialLogin module="CustomModule_SocialLogin">
<file>CustomModule/sociallogin.xml</file>
</CustomModule_SocialLogin>
</updates>
</layout>
</frontend>
<global>
<blocks>
<CustomModule_SocialLogin>
<class>CustomModule_SocialLogin_Block</class>
</CustomModule_SocialLogin>
</blocks>
<models>
<CustomModule_SocialLogin>
<class>CustomModule_SocialLogin_Model</class>
</CustomModule_SocialLogin>
</models>
<helpers>
<CustomModule_SocialLogin>
<class>CustomModule_SocialLogin_Helper</class>
</CustomModule_SocialLogin>
</helpers>
</global>
</config>
My block file -:
class CustomModule_SocialLogin_Block_Qa extends Mage_Core_Block_Template{
public function getText()
{
$name='test';
return $name;
}
}
custom module layout update file :-
<layout version="0.1.0">
<default>
<reference name="content" translate="label">
<block type="custommodule_sociallogin/qa" name="SocialLogin.qa" template="CustomModule/SocialLogin/questionans.phtml" />
</reference>
</default>
</layout>
my template file :-
<?php
echo $this->getText()->toHtml();
//echo $this->getText();
?>
Please help me to solve this error .
You need to correct your module layout file. I have corrected the block type.
<layout version="0.1.0">
<default>
<reference name="content" translate="label">
<block type="sociallogin/qa" name="SocialLogin.qa" template="CustomModule/SocialLogin/questionans.phtml" />
</reference>
</default>
In template file :-
<?php
echo $this->getText();
?>
Module is working on local server but is not working after moving to the Linux server.Im sure all the file are in caps only please point out the error where i missed
Apptha_Subscription.xml
<config>
<modules>
<Apptha_Subscription>
<active>true</active>
<codePool>local</codePool>
</Apptha_Subscription>
</modules>
</config>
confix.xml
<config>
<modules>
<Apptha_Subscription>
<version>0.1.0</version>
</Apptha_Subscription>
</modules>
<frontend>
<routers>
<subscription>
<use>standard</use>
<args>
<module>Apptha_Subscription</module>
<frontName>subscription</frontName>
</args>
</subscription>
</routers>
<layout>
<updates>
<subscription>
<file>subscription.xml</file>
</subscription>
</updates>
</layout>
<translate>
<modules>
<Apptha_Subscription>
<files>
<default>Apptha_subscription.csv</default>
</files>
</Apptha_Subscription>
</modules>
</translate>
</frontend>
<global>
<blocks>
<subscription>
<class>Apptha_Subscription_Block</class>
</subscription>
</blocks>
<models>
<subscription>
<class>Apptha_Subscription_Model</class>
<resourceModel>subscription_mysql4</resourceModel>
</subscription>
<subscription_mysql4>
<class>Apptha_Subscription_Model_Mysql4</class>
<entities>
<subscriptionpaymentdetails>
<table>subscription_payment_details</table>
</subscriptionpaymentdetails>
<subscriptionorderdetails>
<table>subscription_order_details</table>
</subscriptionorderdetails>
</entities>
</subscription_mysql4>
</models>
<helpers>
<subscription>
<class>Apptha_Subscription_Helper</class>
</subscription>
</helpers>
</global>
<admin>
<routers>
<subscription>
<use>admin</use>
<args>
<module>Apptha_Subscription</module>
<frontName>subscription</frontName>
</args>
</subscription>
</routers>
</admin>
<global>
<events>
<customer_register_success>
<observers>
<airhotels>
<type>singleton</type>
<class>Apptha_Subscription_Model_Observer</class>
<method>customer_register_success</method>
</airhotels>
</observers>
</customer_register_success>
</events>
</global>
</config>
block
Subscription.php
class Apptha_Subscription_Block_Subscription extends Mage_Core_Block_Template
{
/**
* Method to get the layouts
*
* #return void
*/
public function _prepareLayout()
{
return parent::_prepareLayout();
}
/**
* Method to get the initial details of before payment of customer
*
* #return array
*/
public function intialDetailsBPay()
{
if(Mage::getSingleton('customer/session')->isLoggedIn())
{
$customerData = Mage::getSingleton('customer/session')->getCustomer();
$customerId = $customerData->getId();
return $intialDetailsBPay = Mage::getModel('subscription/subscriptionpaymentdetails')->load($customerId,'customer_id');
}
}
}
<p>controller</p>
IndexController.php
class Apptha_Subscription_IndexController extends Mage_Core_Controller_Front_Action {
/*
* this method privides default action.
*/
public function indexAction()
{
/*
* Initialization of Mage_Core_Model_Layout model
*/
$this->loadLayout();
/*
* Building page according to layout confuration
*/
$this->renderLayout();
}
public function insertsubscribeAction()
{
$this->loadLayout();
Mage::app()->getLayout()->getBlock('subscription_subscription');
$this->renderLayout();
}
}
layout/subscription.xml
<layout version="0.1.0">
<!--Page handle -->
<subscription_index_index>
<!-- reference tag specifies the block where we a going to add child block -->
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<!-- Our page content block -->
<block type="subscription/subscription" name="subscription" template="subscription/subscription.phtml">
</block>
</reference>
</subscription_index_index>
<subscription_subscribe_insertsubscribe>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<!-- Our page content block -->
<block type="subscription/subscription" name="subscription" template="subscription/paypalbutton.phtml">
</block>
</reference>
</subscription_subscribe_insertsubscribe>
</layout>
If the same module is working on Localhost but not after migration, there is high possibility that permissions are not proper for the migrated files on your linux server. I will suggest please check permissions for all module files.
Secondly, make sure there is no dependency which is remaining to be migrated.
I am creating a module for creating new tab in User's myaccount. I have successfully added a tab named "My Special Products".
Problem is that when i click on that tab it's redirect to 404 error page. I am not able to getting the problem.
My layout xml(customtabs.xml) code is:
<?xml version="1.0"?>
<layout version="0.1.0">
<customer_account>
<!-- Mage_Review -->
<reference name="customer_account_navigation" before="-" >
<action method="addLink" translate="label" module="customer">
<name>newtab</name>
<url>customer/newtab/</url>
<label>My Special Products</label>
</action>
</reference>
</customer_account>
<customer_account translate="label">
<label>Customer My Special Products</label>
<update handle="customer_account"/>
<reference name="my.account.wrapper">
<block type="customer/newtab_newtab" name="customer_newtab_newtab" template="customer/newtab/newtab.phtml"/>
</reference>
</customer_account>
</layout>
My template page is at template\customer\newtab\newtab.phtml
My config.xml for module "Customtabs" is :
<?xml version="1.0"?>
<config>
<modules>
<Fishpig_Customtabs>
<version>0.1.0</version>
</Fishpig_Customtabs>
</modules>
<global>
<blocks>
<customtabs>
<class>Fishpig_Customtabs_Block</class>
</customtabs>
</blocks>
<models>
<customtabs>
<class>Fishpig_Customtabs_Model</class>
</customtabs>
</models>
<helpers>
<customtabs>
<class>Fishpig_Customtabs_Helper</class>
</customtabs>
</helpers>
</global>
<frontend>
<layout>
<updates>
<customtabs>
<file>Customtabs.xml</file>
</customtabs>
</updates>
</layout>
</frontend>
<adminhtml>
<layout>
<updates>
<customtabs>
<file>customtabs.xml</file>
</customtabs>
</updates>
</layout>
<events>
<catalog_product_save_after>
<observers>
<fishpig_save_product_data>
<type>singleton</type>
<class>customtabs/observer</class>
<method>saveProductTabData</method>
</fishpig_save_product_data>
</observers>
</catalog_product_save_after>
</events>
</adminhtml>
</config>
Any one can help me where is the problem.
You set url for this tab as <url>customer/newtab/</url>
so, you should have controller of newtab somewhere,
First you need to add <routers> part in your module's config.xml, put this in <frontend>.
<routers>
<customtabs>
<use>standard</use>
<args>
<module>Fishpig_Customtabs</module>
<frontName>customtabs</frontName>
</args>
</customtabs>
</routers>
change <url>customer/newtab/</url> to <url>customtabs/newtab</url> in customtabs.xml file.
also put,
<customtabs_newtab_index>
<update handle="customer_account"/>
<reference name="my.account.wrapper">
<block type="customer/newtab_newtab" name="customer_newtab_newtab" template="customer/newtab/newtab.phtml"/>
</reference>
</customtabs_newtab_index>
create a controller at code/local/Fishpig/Customtabs/controllers/NewtabController.php
in that your code should be
class Fishpig_Customtabs_NewtabController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
if(!Mage::getSingleton('customer/session')->isLoggedIn())
{
Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account'));
return false;
}
$this->loadLayout();
$this->_initLayoutMessages('customer/session');
$this->getLayout()->getBlock('head')->setTitle($this->__('My Special Products'));
$this->renderLayout();
}
}
Add a block file as app/code/local/Fishpig/Customtabs/Block/Customtabs.php
and put there code,
class Fishpig_Customtabs_Block_Customtabs extends Mage_Core_Block_Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getCustomtabs()
{
if (!$this->hasData('customtabs')) {
$this->setData('customtabs', Mage::registry('customtabs'));
}
return $this->getData('customtabs');
}
}
and change your block type in your customtabs.xml file
<block type="customtabs/customtabs" name="customer_newtab_newtab" template="customer/newtab/newtab.phtml" />