Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
To create a new page
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

Hello All,

I want to create a new page like
http://localhost:145/sampleorder/tsample.

Can anybody help? I need the steps please, right from creating a controller, aphtml page, etc..

I want to create a form under the URL mentioned above.
Please advice.

Regards,
DevHasMag

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

1. Declare a module:
app/etc/local.xml:

<!-- add this: -->
  <
modules>
    <
Mage_Sampleorder>
      <
codePool>local</codePool>
      <
active>true</active>
    </
Mage_Sampleorder>
  </
modules>
<!-- 
before: -->
</
config>

2. Create module configuration:
app/code/local/Mage/Sampleorder/etc/config.xml:

<?xml version="1.0"?>
<config>
  <global>
    <
blocks>
<!-- declare 
sampleorder block group -->
      <
sampleorder>
        <class>
Mage_Sampleorder_Block</class>
      </
sampleorder>
    </
blocks>
  </global>

  <
frontend>
    <
routers>
<!-- declare 
a router for urls starting with /sampleorder -->
      <
sampleorder>
        <use>
standard</use>
        <
args>
          <
module>Mage_Sampleorder</module>
          <
frontName>sampleorder</frontName>
        </
args>
      </
sampleorder>
    </
routers>

    <
layout>
      <
updates>
<!-- declare 
a file that will supply layout updates for your controllers -->
        <
sampleorder>
          <
file>sampleorder.xml</file>
        </
sampleorder>
      </
updates>
    </
layout>
  </
frontend>
</
config>

3. Create a controller:
app/code/local/Mage/Sampleorder/controllers/TsampleController.php:

<?php

class Mage_Sampleorder_TsampleController extends Mage_Core_Controller_Front_Action
{
  
public function indexAction()
  
{
    $this
->loadLayout();
    
$this->renderLayout();
  
}
}

4. Create a custom functionality block (optional):
app/code/local/Mage/Sampleorder/Block/Tsample.php:

<?php

class Mage_Sampleorder_Block_Tsample extends Mage_Core_Block_Template
{
  
public function getSomeValue()
  
{
    
return 'this value is taken from custom block';
  
}
}

5. Create a template that you would like to use on this page:
app/design/frontend/default/default/template/sampleorder/tsample.phtml:

<p><?=$this->__("Translated label for some value: %s"$this->getSomeValue())?></p>

6. Create a layout update file:
app/design/frontend/default/default/layout/sampleorder.xml:

<?xml version="1.0"?>
<layout>
  <
sampleorder_tsample_index>
<!-- 
insert tsample blocks into middle column (content) -->
    <
reference name="content">
<!-- 
create generic template block -->
      <
block type="core/template" name="sampleorder.tsample.generic" template="sampleorder/tsample.phtml">
        <
action method="setSomeValue"><value>this value is assigned from layout</value></action>
      </
block>
 
<!-- 
create tsample block -->
      <
block type="sampleorder/tsample" name="sampleorder.tsample.custom" template="sampleorder/tsample.phtml"/>
    </
reference>
  </
sampleorder_tsample_index>
</
layout>
 
Magento Community Magento Community
Magento Community
Magento Community
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

Thanks a lot Moshe.
But now when i execute this url http://localhost:145/sampleorder/tsample, I am not able to see my HTML code executed.
Please help.
I request you to please give me your email id, so that i can chat and clear my doubts.

Regards,
DevHasMag.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Let’s try resolve the issue in the forums, so other members can benefit from the experience.

First, make sure that Magento cache is either disabled or refreshed after changes to configuration.

What does it show on this page? Is it empty/blank or shows error 404?

 
Magento Community Magento Community
Magento Community
Magento Community
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

It shows me the template.In the Tsamplecontroller.php, under the indexAction, I have given echo “*******” and in my tsample.phtml, i have given “Hello world”. i can see only “*********”. I cant see Hello world printed. Please tell me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Try adding the contents of <sampleorder_tsample_index> tag from step 6 into app/design/frontend/default/default/layout/main.xml, i forgot that this change wasn’t commited in last release, my bad.

 
Magento Community Magento Community
Magento Community
Magento Community
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

Moshe,
Thank you very much. Thats a gr8 help from you. It worked finally. But the problem is I am getting the output twice.
Like this. Hello WorldHello World.
What can be the problem. How to resolve this?
Please tell me.

Regards,
DevHasMag

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

In step 6 i’ve provided 2 examples, for using custom block, or using generic template block:

<!-- create generic template block -->
      <
block type="core/template" name="sampleorder.tsample.generic" template="sampleorder/tsample.phtml">
        <
action method="setSomeValue"><value>this value is assigned from layout</value></action>
      </
block>
<!-- 
generic block until here --> 

<!-- 
create tsample block -->
      <
block type="sampleorder/tsample" name="sampleorder.tsample.custom" template="sampleorder/tsample.phtml"/>
<!-- 
custom block until here -->

If you do not need any custom functionality in your template, leave only the first <block> tag, if you need to supply any custom calculations, use the 2nd one.
If you use generic ‘core/template’ block, you can skip step 4.

 
Magento Community Magento Community
Magento Community
Magento Community
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

Thanks a lot Moshe.

That worked finally.
I also have somemore queries. I kindly request you for your support and help till i get used to Magento.

Regards,
DevHasMag

 
Magento Community Magento Community
Magento Community
Magento Community
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

Moshe,
On ly local system, It works fine.
When i upload on the server, I dont see the HTML ouput.
In the admin panel, There is no cache management.
Please advice.
On the server, the application is running under the URL like http://mydomain.com/store/sampleorder/tsample.

Regards,
DevHasMag

 
Magento Community Magento Community
Magento Community
Magento Community
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

Moshe,
When i create the same files on the server, I am not getting the HTML view.
http://mydomain.com/store/sampleorder/tsample.
In the admin panel, There is no cache management.
What do to?
Please advice.

Regards,
DevHasMag

 
Magento Community Magento Community
Magento Community
Magento Community
 
DevHasMag
Jr. Member
 
Total Posts:  18
Joined:  2007-12-19
 

Moshe,

Please help me. On on my local system, It works fine.
When i upload on the server, I dont see the HTML ouput.
In the admin panel, There is no cache management.
Please advice.

On the server, the application is running under the URL like http://mydomain.com/store/sampleorder/tsample.

Also i dont see a file main.xml in the version of magento installed on the server.

I cannot find the file app/design/frontend/default/default/layout/main.xml
I uploaded a main.xml. But its not reading.
Kindly advice.

Regards,
DevHasMag

 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

Hi,

I succeded in creating this page, but now i’d like to use the Magento DB connection. Which object do I need and how ?

Thanx,
Antoine

 
Magento Community Magento Community
Magento Community
Magento Community
 
beowax
Sr. Member
 
Total Posts:  94
Joined:  2007-12-17
Lille, France
 

Hi,

I used this code, which works quite fine :

$connexion    Mage::getSingleton('core/resource')->getConnection('catalog_write');
$select        $connexion->select()
->
from("tbl_magasins", array('MAGASIN_ID''MAGASIN_Libelle''MAGASIN_LibelleComplement''MAGASIN_Adresse''MAGASIN_AdresseComplement''MAGASIN_CP''MAGASIN_Ville''MAGASIN_Pays''MAGASIN_Tel''MAGASIN_Code'));
$magasins $connexion->fetchAll($select);

It seems OK, but i d’like a confirmation from the developers wink

Regards,
A.

 
Magento Community Magento Community
Magento Community
Magento Community
 
aimos
Jr. Member
 
Total Posts:  18
Joined:  2007-12-28
 

can it be that the directory structure changed?

first step: /app/etc/local.xml looks not like it a module xml, but there is a subdirectory “modules” which looks correct.

Question: If I want to extend it now in my Own “Namespace” Can I create Myname_All.xml with all the modules in it or Do I have to edit the Mage_All.xml file?

Ciao

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@aimos:

can it be that the directory structure changed?

first step: /app/etc/local.xml looks not like it a module xml, but there is a subdirectory “modules” which looks correct.

you are correct, the directory structure has changed to simple file drop-in declaration of custom modules.

Question: If I want to extend it now in my Own “Namespace” Can I create Myname_All.xml with all the modules in it or Do I have to edit the Mage_All.xml file?

you are correct again, each package should drop its own file with list of declared modules.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2