Magento Forum

   
Problem adding new page to module
 
coldwired
Jr. Member
 
Total Posts:  19
Joined:  2008-07-15
 

Hi,

I’m having trouble adding an additional page / block to my reminders module.  I have the url http://mysite/index.php/reminders which works fine, I want to add a new page with a new template to http://mysite/index.php/reminders/view.  The problem is I can’t work out how to do that, I think it should be done in the reminders.xml in the layout folder in design.  This is what I have:

<reminders_index_index>
    <
reference name="content">
      <
block type="reminders/reminders" name="reminders">
        <
block type="reminders/view" name="view" as="view" />
      </
block>
    </
reference>
  </
reminders_index_index>

I have two template files created; one called reminders.phtml and one called view.phtml in app\design\frontend\default\default\template\reminders.

What else do I need to do to get this to work?

Regards,
Colin.

 
Magento Community Magento Community
Magento Community
Magento Community
 
altansar
Member
 
Total Posts:  51
Joined:  2008-07-08
 

Hi Coldwired,

to create your own module, you could follow this tutorial. This is not for creating the same module than your, but it shows the differents steps.
Hope that will help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
coldwired
Jr. Member
 
Total Posts:  19
Joined:  2008-07-15
 

Hi,

Thanks for the quick response, much appreciated.  I’ve had a look at the tutorial before but it doesn’t really help me as I’m looking to add a second page / block and all the tutorials seem to just show one.  I think I’m missing something really obvious here, I just can’t see it…

Cheers,
Col.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jwoods
Jr. Member
 
Avatar
Total Posts:  27
Joined:  2008-04-23
Boston MA
 

I’ve added a simple Blog functionality to Magento for the client to use as a News section. I need both “/blog/post/108” and “/blog/page/3”.
I’ve got this:

<frontend>
    <
routers>
    <
blog>
        <use>
standard</use>
        <
args>
            <
module>MyCompany_Blog</module>
            <
frontName>blog</frontName>
        </
args>
    </
blog>
    </
routers>
    ....
</
frontend>
....
<global>
    <
rewrite>
        <!-- 
This is an identifier for your rewrite that should be unique -->
        <
MyCompany_Blog_post>
            <
from><![CDATA[#^/blog/post/([0-9]*)$#]]></from>
            
<to>/blog/index/post/id/$1</to>
        </
MyCompany_Blog_post>
        <
MyCompany_Blog_page>
            <
from><![CDATA[#^/blog/page/([0-9]*)$#]]></from>
            
<to>/blog/index/index/page/$1</to>
        </
MyCompany_Blog_page>
        ....
    </
rewrite>
    ....
</global>
The <to> nodes are in this format: [Module]/[controller]/[action].
Here’s my blog.xml file in /frontend/interface/template/layout/blog.xml:
<layout version="0.1.0">
    <default>
    </default>
    <
blog_index_index>
        <
reference name="content">
            <
block type="core/template" name="blog" template="blog/blog.phtml" />
        </
reference>
    </
blog_index_index>
    <
blog_index_post>
        <
reference name="content">
            <
block type="core/template" name="post" template="blog/post.phtml" />
        </
reference>
    </
blog_index_post>
</
layout>
The childnodes of <layout> are in the format [module]_[controller]_[action]
Does that answer your question?

 
Magento Community Magento Community
Magento Community
Magento Community
 
coldwired
Jr. Member
 
Total Posts:  19
Joined:  2008-07-15
 

Hi,

That looks great - I’ll give it a go.

Cheers!
Col.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Devpen
Jr. Member
 
Total Posts:  11
Joined:  2008-07-30
 

hey there.
i’ve been making a similar news module.

my URLs work like this:
eg
/shop/news/articles/6

where 6 is the article id.

it passes through to my article.phtml page, but i am unsure how to access the 6, and pass it into my
$news = Mage::getModel(’news/news’)->

to load this specific article.

any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikefido
Guru
 
Avatar
Total Posts:  481
Joined:  2008-07-11
New Haven, CT
 

@Sonassi

It’s something like

$this->getRequest->getParams('param_name');

Try logging / echoing / print_r-ing different variations of that to see how it works exactly (esp use getParams() - with no parameters there to see what it returns).

Im referencing other controllers for this - particularly the add to cart one, as I know it uses a product id in the URL - check out:
app/code/core/Mage/checkout/controllers/CartController.php

I believe the URLs go someting like controller/method/parameter - so getting the paramter will probably return your “6” (not positive on that)

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top