1

I'm trying to figure out why Magento is not highlighting my new customer account link when I access the corresponding page. Here is my code :

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
          <reference name="content">
          </reference>
      </default>
    <customer_account translate="label">
        <reference name="customer_account_navigation">
            <action method="addLink"><name>Mes parrainages</name><path>mesparrainages/index/index/</path><label>Mes parrainages</label></action>
        </reference>
    </customer_account>
      <mesparrainagesrouter_index_index>
        <update handle="customer_account"/>
           <reference name="my.account.wrapper">
                <block type="parrainage/mesparrainagesblock" name="bloc_mesparrainages" as="bloc_mesparrainages" template="parrainage/mesparrainages.phtml" />
           </reference>
      </mesparrainagesrouter_index_index>
</layout>

I'm using CE 1.9, maybe they changed the way it works.. Somebody have an idea please ?

Edit: Here is my config.xml:

<?xml version="1.0"?>
<config>
  <modules>
    <Motion4Ever_Parrainage>
      <version>0.1.0</version>
    </Motion4Ever_Parrainage>
  </modules>
  <frontend>
      <routers>
          <mesparrainagesrouter>
              <use>standard</use>
              <args>
                  <module>Motion4Ever_Parrainage</module>
                  <frontName>mesparrainages</frontName>
              </args>
          </mesparrainagesrouter>
      </routers>
      <layout>
          <updates>
              <parrainage>
                  <file>parrainage/layout.xml</file>
              </parrainage>
          </updates>
      </layout>
  </frontend>
  <global>
    <blocks>
       <parrainage>
            <class>Motion4Ever_Parrainage_Block</class>
       </parrainage>
    </blocks>
    <template>
        <email>
            <email_parrainage module="parrainage">
                <label>Email parrainage</label>
                <file>email_parrainage.html</file>
                <type>html</type>
            </email_parrainage>
        </email>
    </template>
    <helpers>
      <parrainage>
        <class>Motion4Ever_Parrainage_Helper</class>
      </parrainage>
    </helpers>
    <models>
      <parrainage>
        <class>Motion4Ever_Parrainage_Model</class>
        <resourceModel>parrainage_mysql4</resourceModel>
      </parrainage>
      <parrainage_mysql4>
        <class>Motion4Ever_Parrainage_Model_Mysql4</class>
        <entities>        
              <filleul>
                <table>filleul</table>
              </filleul>
        </entities>
      </parrainage_mysql4>
    </models>
    <resources>
      <parrainage_setup>
        <setup>
          <module>Motion4Ever_Parrainage</module>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </parrainage_setup>
      <parrainage_write>
        <connection>
          <use>core_write</use>
        </connection>
      </parrainage_write>
      <parrainage_read>
        <connection>
          <use>core_read</use>
        </connection>
      </parrainage_read>
      <customerattribute1407966696_setup>
        <setup>
          <module>Motion4Ever_Parrainage</module>
          <class>Mage_Customer_Model_Entity_Setup</class>
        </setup>
        <connection>
          <use>core_setup</use>
        </connection>
      </customerattribute1407966696_setup>
      <customerattribute1407966696_write>
        <connection>
          <use>core_write</use>
        </connection>
      </customerattribute1407966696_write>
      <customerattribute1407966696_read>
        <connection>
          <use>core_read</use>
        </connection>
      </customerattribute1407966696_read>
    </resources>
    <events>
      <customer_register_success> <!-- identifier of the event we want to catch -->
        <observers>
          <customer_register_success_handler> <!-- identifier of the event handler -->
            <type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
            <class>parrainage/observer</class> <!-- observers class alias -->
            <method>registerCustomerObserve</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </customer_register_success_handler>
        </observers>
      </customer_register_success>
    </events>
  </global>
</config>

Here is my template :

<div class="dashboard">
    <div class="page-title">
        <h1><?php echo $this->__('Mes parrainages'); ?></h1>
    </div>
    <form action="<?php echo Mage::getUrl('mesparrainages/index/addfilleul/'); ?>" method="post" autocomplete="off" id="form-validate" class="scaffold-form" enctype="multipart/form-data">
    <input type="hidden" name="parrain_customer_id" value="<?php echo Mage::getSingleton('customer/session')->getCustomer()->getId(); ?>">
    <div class="fieldset">
        <h2 class="legend">Ajouter un filleul</h2>
        <ul class="form-list">
            <li>
                <label for="email" class="required">Adresse email</label>
                <div class="input-box">
                    <input type="email" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" name="email_filleul" id="email" title="Adresse email" class="input-text required-entry validate-email">
                    <button type="submit" title="Enregistrer" class="button"><span><span>Ajouter filleul</span></span></button>
                </div>
            </li>
        </ul>
    </div>
</form>
    <table class="data-table">
        <col />
        <col width="160" />
        <col width="120" />
        <col width="60" />
        <thead>
            <tr>
                <th><?php echo $this->__('Email du filleul') ?></th>
                <th><?php echo $this->__('Statut') ?></th>
                <th><?php echo $this->__('Code promo') ?></th>
                <th></th>
            </tr>
        </thead>
        <?php $filleuls = $this->getFilleuls(); 
            if($filleuls){ ?>
                <tbody id="filleuls">
                <?php foreach($filleuls as $filleul): ?>
                    <tr>
                        <td><?php echo $filleul->getEmailFilleul(); ?></td>
                        <td><?php echo $this->getStatut($filleul); ?></td>
                        <td></td>
                        <td><button id="resend" data-email="<?php echo $filleul->getEmailFilleul(); ?>" type="submit" title="Renvoyer" class="button"><span><span>Renvoyez l'email</span></span></button></td>
                    </tr>
                <?php endforeach ?>
                </tbody>
            <?php }else{ ?>
                <tbody>
                    <tr>
                        <td colspan = "4">Vous n'avez pas encore de filleuls !</td>
                    </tr>
                </tbody>
            <?php } ?>
    </table>
</div>

<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
    $('#resend').on("click",function(e){
        e.preventDefault();
        if($(this).text()=="Renvoyez l'email"){
            var email = $(this).data("email");
            $.ajax({
                url: "<?php echo Mage::getUrl('mesparrainages/index/sendemail/'); ?>",
                type: "POST",
                data: { email : email },
                context: this,
                success:function(){
                    $(this).text("Email envoyé !");
                }
            });
        }
    });
    $("#form-validate").on("submit",function(e){
        e.preventDefault();
        var email = $(this).find('#email').val();
        $.ajax({
            url: "<?php echo Mage::getUrl('mesparrainages/index/addfilleul/'); ?>",
            type: "POST",
            data: $(this).serialize(),
            context: this,
            success:function(data){
                $("#filleuls").prepend("<tr><td>"+email+"</td><td>Pas encore inscrit</td><td>Aucun</td><td><button id='resend' type='submit' title='Renvoyer' class='button'><span><span>Email envoyé !</span></span></button></td></tr>");
                $(this).find('#email').val(null);
            },
            error:function(xhr, status, error){
                alert(error);
            }
        });
    })
</script>
7
  • provide template.phtml file and config.xml file of your module Aug 14, 2014 at 4:01
  • @programmer_rkt I edited the first post ;) Aug 14, 2014 at 4:32
  • show your full config.xml and template.phtml Aug 14, 2014 at 5:26
  • @programmer_rkt okey ;) sorry for that but i'm french, and i'm too tired to change all the names, i just did not sleep at all tonight Aug 14, 2014 at 5:29
  • my.account.wrapper is this block is already existing one ? Aug 14, 2014 at 5:35

1 Answer 1

1

Your block definition is wrong here

<block type="modulename/blockname" name="block_name" template="template.phtml" />

As per your module configuration it should look like

<block type="parrainage/blockname" name="block_name" as="block_name" template="template.phtml" />

since parrainage is the alias for your module's block. But in order to ensure this block render its content, you may also need to look on this

1. You should have block defined in backend

Location : app/code/local/Motion4Ever/Parrainage/Block/Blockname.php

<?php
class Motion4Ever_Parrainage_Block_Blockname extends Mage_Core_Block_Template {

}

Without defining this block class, Magento would not understand which block that you are referencing in layout file

2. You need to ensure the parent block is defined before referencing the block.

In this case, this step won't be necessary. Since it is defined in customer.xml

1
  • This isn't solving my problem.. My block is correctly defined, since it's actually working, only the left hand side highlighting of the menu is not ;) I'm adding my proper layout.xml file Aug 14, 2014 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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