0

I created a custom module for my internship, I have to add an item to the users menu in the frontend

  • MY ACCOUNT
  • ACCOUNT DASHBOARD
  • ACCOUNT INFORMATION
  • ADDRESS BOOK
  • MY ORDERS
  • BILLING AGREEMENTS
  • RECURRING PROFILES
  • MY PRODUCT REVIEWS
  • MY TAGS
  • MY WISHLIST
  • MY APPLICATIONS
  • NEWSLETTER SUBSCRIPTIONS
  • MY DOWNLOADABLE PRODUCTS
  • REGISTER MOVIES`

And I was successful, I added the menu "Register Movies" my problem is that when I click on it it is redirected to a 404 screen, because I have not yet set any PHTML files, I would like to know where I can set this File I already did it once and it worked, but the sidebar with the other menu items disappears, I would like to keep them at the same time that I am in my page.

Like this the same as it is while you are in "My Orders" on the right side> Shows the "My Account" in the left menu < enter image description here

local/Teste/Cadastro/Block/Navegação.php

<?php
class Teste_Cadastro_Block_AddSubscriptionLink extends Mage_Customer_Block_Account_Navigation 
{
    public function addSubscriptionsLink()
    {
        $label = ''; // get label with balance here
        $this->addLink(
            $label,
            "[url]",
            "[title]"
        );
    }
}
?>

local/Teste/Cadastro/Helper/cadastro.php

<?php
class Teste_Cadastro_Helper extends Mage_Core_Helper_Abstract
{
    public function getSubscriptionsLabel() 
    {
        $label = 'teste'; // get label with balance here
        return $label;
    }
}
?>

default/layout/cadastro.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <customer_account>
        <reference name="customer_account_navigation">
            <action method="addLink" translate="label" module="cadastro">
                <label helper="cadastro/getSubscriptionsLabel" />
                <path>customer/account/teste</path>
                <name>CADASTRAR FILMES</name>
            </action>        
        </reference>
    </customer_account>
</layout>`

local/Teste/Cadastro/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Teste_Cadastro>
            <version>0.1.1</version>
        </Teste_Cadastro>
    </modules>
    <frontend>
        <routers>
            <cadastro>
                <use>standard</use>
                <args>
                    <module>Teste_Cadastro</module>
                    <frontName>cadastro</frontName>
                </args>
            </cadastro>
        </routers>
        <layout>
            <updates>
                <cadastro>
                    <file>cadastro.xml</file>
                </cadastro>
            </updates>
        </layout>
    </frontend>
    <admin>
       <routers>
           <adminhtml>
                <args>
                    <modules>
                        <cadastro before="Mage_Adminhtml">Teste_Cadastro_Adminhtml</cadastro>
                    </modules>
                </args>
            </adminhtml>
       </routers>
    </admin>
    <adminhtml>
        <menu>
            <cadastro module="cadastro">
               <title>cadastro</title>
               <sort_order>71</sort_order>              
               <children>
                   <items module="cadastro">
                       <title>Manage Items</title>
                       <sort_order>0</sort_order>
                       <action>adminhtml/cadastro</action>
                   </items>
               </children>
           </cadastro>
        </menu>
        <acl>
            <resources>
                <all>
                    <title>Allow Everything</title>
                </all>
                <admin>
                    <children>
                        <cadastro>
                            <title>cadastro Module</title>
                            <sort_order>200</sort_order>
                        </cadastro>
                    </children>
                </admin>
            </resources>  
        </acl>
        <layout>
            <updates>
                <cadastro>
                    <file>cadastro.xml</file>
                </cadastro>
            </updates>
        </layout>
    </adminhtml>  
    <global>
        <models>
            <cadastro>
                <class>Teste_Cadastro_Model</class>
                <resourceModel>cadastro_mysql4</resourceModel>
            </cadastro>
            <cadastro_mysql4>
                <class>Teste_Cadastro_Model_Mysql4</class>
                <entities>
                    <cadastro>
                        <table>cadastro</table>
                    </cadastro>
                </entities>
            </cadastro_mysql4>
        </models>
        <resources>
            <cadastro_setup>
                <setup>
                    <module>Teste_Cadastro</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </cadastro_setup>
            <cadastro_write>
                <connection>
                    <use>core_write</use>
                </connection>
             </cadastro_write>
            <cadastro_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </cadastro_read>
        </resources>
        <blocks>
            <cadastro>
                <rewrite>
                    <account_navigation>Teste_Cadastro_Block_AddSubscriptionLink</account_navigation>
                </rewrite>
            </cadastro>
            <cadastro>
                <class>Teste_Cadastro_Block</class>
            </cadastro>
        </blocks>
        <helpers>
            <cadastro>
                <class>Teste_Cadastro_Helper</class>
            </cadastro>
        </helpers>
    </global>
</config> `


In the config.xml that is showing other codes is referring to another part of my training, I have to do the backend part (which is already working and registering what I need in DATABASE) I just need to do the frontend part now, I need to put in to insert data into a table (register) and view, but only change / delete in the backend, this I already did, I just need the frontend, thank you to anyone who can help.
0

Add the following code in layout xml

<layout version="0.1.0">
   <your_handle translate="label">
       <label>Custom Page</label>
          <reference name="head">
                 <action method="setTitle"><title>Custom Page</title></action> <!--Page Title-->
         </reference>
     <!-- Mage_Customer -->
     <update handle="customer_account"/>
      <reference name="my.account.wrapper">
        <!-- Your block goes here -->
    </reference>
  </your_handle>
</layout>

Update your_handle with your custom controller handle of the new page. <update handle="customer_account"/> is responsible for loading the left navigation menu in your page. Also add the add the respective phtml.

| improve this answer | |
  • Hello friend, thanks for the help, I tried to modify the xml the way you said, but I did not succeed, the menu item I added disappeared – Gustavo Souza Jul 14 '17 at 16:22
  • Thank you very much, I was able to solve the problem with a simple change in the tag "cadastro_controller_index" change to "cadastro_index_index" I had not noticed the problem, your comment was of great help – Gustavo Souza Jul 14 '17 at 17:45
0

I've searched the "handle" tag that I did not know what it was for, I have 1 month experience with Magento, I'm still scared of its structure but I see that if you master this tool it is Great, now I was able to add all the elements you requested there, but when I click on my menu item it still opens the page without anything, the phtml file is still white but it also does not get the "handle" I noticed Also that it is not going to the template that I put there, I have to add the "cadastro.phtml" in <path> for it to be redirected.

Do I have to make any more changes to some file? I've also been seeing that whoever wears the handle creates observers, would that be the case? In "URL" "title" blocks should I specify the paths or something of the type?

 <?xml version="1.0"?>
<layout version="0.1.0">
     <cadastro_controller_index> <!-- module here matches node directly beneath <routers> in config.xml -->
       <update handle="customer_account"/> <!-- include existing customer account layout --> 
       <reference name="my.account.wrapper"> <!-- target parent block -->
           <block type="core/template" name="cadastro" template="cadastro/cadastro.phtml"/>
           <block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml" /> <!-- add a back link -->
       </reference>
   </cadastro_controller_index>
    <customer_account>
        <reference name="customer_account_navigation">
            <action method="addLink">
                <name>cadastro_filme</name>
                <path>cadastro</path>
                <label>cadastrar filme</label>
            </action>
        </reference>
    </customer_account>
</layout>  
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.