tags:

views:

39

answers:

1

I am trying to create a magento shopping cart module but things arent working out. Here is my steps

I first create a xml in the app etc...

<?xml version="1.0"?>
<config>
    <modules>
        <mywebwow_AdvancedCatalog>
            <active>true</active>
            <codePool>local</codePool>
        </mywebwow_AdvancedCatalog>
    </modules>
</config>

Then I create my folder in the local pool

/local/mywebwow/AdvancedCatalog/

In that folder I put the following files

/Block/AdvanceCatalog.php
/controllers/indexController.php
/etc/config.xml

I put the following in the block

AdvancedCatalog.php

<?php
class mywebwow_AdvancedCatalog_Block_Advancedcatalog extends Mage_Core_Block_Template
{
    public function _prepareLayout()
    {
        return parent::_prepareLayout();
    }

    public function getHelloworld()
    {
        return 'Hello world';
    }
}

indexController.php

<?php
class mywebwow_AdvancedCatalog_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <mywebwow_AdvancedCatalog>
            <version>0.1.0</version>
        </myweboww_AdvancedCatalog>
    </modules>
    <frontend>
        <routers>
            <AdvancedCatalog>
                <use>standard</use>
                <args>
                    <module>mywebwow_AdvancedCatalog</module>
                    <frontName>advancedcatalog</frontName>
                </args>
            </AdvancedCatalog>
        </routers>
        <layout>
            <updates>
                <AdvancedCatalog>
                    <file>advancedcatalog.xml</file>
                </AdvancedCatalog>
            </updates>
        </layout>
    </frontend>
    <global>
        <blocks>
            <AdvancedCatalog>
                <class>mywebwow_AdvancedCatalog_Block</class>
            </AdvancedCatalog>
        </blocks>
        <helpers>
            <AdvancedCatalog>
                <class>mywebwow_AdvancedCatalog_Helper</class>
            </AdvancedCatalog>
        </helpers>
    </global>
</config>

when i type in website.com/index.php/advancedcatalog/

I get a 404. no page found.

[EDIT]

I changed the block class from MyWebwow_AdvancedCatalog_Block_AdvancedCatalog to MyWebwow_AdvancedCatalog_Block_Advancedcatalog

I added advancedcatalog.xml it looks like the following...

advancedcatalog.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <advancedcatalog_index_index>
        <reference name="content">
            <block type="advancedcatalog/advancedcatalog" name="advancedcatalog" template="advancedcatalog/helloworld.phtml" />
        </reference>
    </advancedcatalog_index_index>
</layout>

then there is the following which I already had

/template/advancedcatalog/helloworld.phtml

helloworld.phtml

<h2><?php echo $this->getHelloworld(); ?></h2>
+1  A: 

A few things to fix, hopefully one will get you moving:

  1. Move your controller from indexController.php to IndexController.php. On case-sensitive systems, this very well could cause the controller not to be found.

  2. Have you defined a layout file? (e.g. advancedcatalog.xml). Your file defines advancecatalog.xml, which seems like it might be a typo, though it could work if you defined that file.

  3. Do you have any views defined? loadLayout will try to load a layout handle for the page and render blocks accordingly. This is where you'll have to specify your advancedcatalog/advancedcatalog block. If you do have a layout and templates, please post those.

  4. Don't use camelcase for the block name, it will confuse Magento. The block will need to be defined as advancedcatalog/advancedcatalog, but that will resolve to mywebwow_AdvancedCatalog_Block_Advancedcatalog (note no second cap). This will be an issue.

Fix those and see if it starts working, let me know if you still have trouble.

Thanks, Joe


You don't necessarily need a model unless you are invoking one. As for #4, it's up to you whether you want to use mixed case on that one. In your config file, you specified the prefix for AdvancedCatalog blocks to be mywebwow_AdvancedCatalog_Block, so the mixed case shouldn't be a problem. Conversely, though, you may want the tag inside of blocks to be lowercased, so that when you invoke your models you can stick w/ the existing Magento convention of lowercase. Do this:

<global>
    <blocks>
        <advancedcatalog>
            <class>mywebwow_AdvancedCatalog_Block</class>
        </advancedcatalog>
    </blocks>
....
Joseph Mastey
Hi, I greatly appreciate your response. I dont get much responses on magento but I appreciate it cause i need it. I edited the code. I changed advancecatalog.xml to advancedcatalog.xml
numerical25
Im looking at number 4. You said use advancecatalog/advancedcatalog. Are you refering to the block type within the layout ?? Also is the mywebwow fine or should I make it Mywebwow_AdvancedCatalog_Block_Advancatalog
numerical25
Thanks for your help alot. I think you pointed me in a good direction. The key to getting this fixed was that there is only suppose to be 1 uppercase letter in the module.
numerical25
Also I did not create a model which I believe is essential.
numerical25