Domanda

Lasciami prefiggere questo dal fatto che sono nuovo al 100% nuovo a magento.

Sto cercando di estendere la pagina Contattaci per consentirmi di aggiungere alcune informazioni alla pagina, come il modulo, in cui non può essere modificato tramite il CMS (in particolare le informazioni sull'indirizzo da iniziare). Ho fatto un sacco di ricerche di Google e ho guardato domande simili qui (questo sembra essere il più vicino: Contattaci Il modulo non viene visualizzato ) ma non lo sto capitando.

Ho provato vari metodi di risoluzione ma attualmente sto cercando di aggiungere un blocco. Tutto quello che sto cercando di fare a questo punto è ottenere il testo "speciale" da mostrare sulla pagina insieme alla forma. Renditi conto che potrebbe essere sbagliato, basta cercare una direzione su ciò che mi manca.

Codice:

etc / modules / tpw_contacts.xml

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

app / code / local / tpw / contatti / controller / indexcontroller.php

<?php
require_once Mage::getModuleDir('controllers', 'Mage_Contacts') . DS . 'IndexController.php';

class TPW_Contacts_IndexController extends Mage_Contacts_IndexController
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}
?>
.

app / code / local / tpw / contatti / etc / config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <TPW_Contacts>
            <version>0.1.0</version>
        </TPW_Contacts>
    </modules>
    <global>
        <blocks>
            <contacts>
                <class>TPW_Contacts_Block</class>
            </contacts>
        </blocks>
    </global>
    <frontend>
        <routers>
            <contacts>
                <args>
                    <modules>
                        <TPW_Contacts before="Mage_Contacts">TPW_Contacts</TPW_Contacts>
                    </modules>
                </args>
            </contacts>
        </routers>
    </frontend>
</config>
.

App / Design / Frontend / Enterprise / Hellov / Layout / Contacts.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="footer_links">
            <action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled"><label>Contact Us</label><url>contacts</url><title>Contact Us</title><prepare>true</prepare></action>
        </reference>
    </default>

    <contacts_index_index translate="label">
        <label>Contact Us Form</label>
        <reference name="head">
            <action method="setTitle" translate="title" module="contacts"><title>Contact Us</title></action>
        </reference>
        <reference name="root">
            <action method="setTemplate"><template>page/1column.phtml</template></action>
            <action method="setHeaderTitle" translate="title" module="contacts"><title>Contact Us</title></action>
        </reference>
        <reference name="content">
            <block type="contacts/location" name="contacts.locationinfo" template="contacts/locationinfo.phtml"/>
        </reference>
        <reference name="content">
            <block type="core/template" name="contactForm" template="contacts/form.phtml"/>
        </reference>
    </contacts_index_index>
</layout>
.

app / code / locale / tpw / contatti / blocco / contact.php

<?php
class TPW_Contacts_Block_Location extends Mage_Core_Block_Template
{
    public function getLocation()
    {
        return 'This is my address!';
    }
}
?>
.

App / Design / Frontend / Enterprise / Hellov / Template / Contatti / LocationInFO.phtml

<p><?php echo $this->getLocation(); ?></p>
.

Il tuo aiuto è apprezzato. Grazie!

È stato utile?

Soluzione

Problema1: anche come used blocks type at contacts/location, quindi significa che questa classe dovrebbe essere mage_contacts_block_location .

Come questo class not exits quindi override in questa classe using another class

<global>
        <blocks>
            <contacts>
                <class>TPW_Contacts_Block</class>
            </contacts>
        </blocks>
    </global>
.

Cambia a

 <global>
            <blocks>
                <customcontacts>
                    <class>TPW_Contacts_Block</class>
                </customcontacts>
        <contacts>
            <rewrite>
                <location>TPW_Contacts_Block_Location</location>
            <rewrite>
        <contacts>
            </blocks>
        </global>
.

Problema2: Altro problema con Posizione del file:

AS TPW_CONTACTS_BLOCK_LOCATION se la posizione dovrebbe essere app/code/local/TPW/Contacts/Block/Location.php da app/code/local/TPW/Contacts/Block/Contacts.php

Step3: Il tuo attuale indexAction non ha generatodicetagcode .in set form post action è impostato da Indexaction Function of Mage_Contacts_IndexController . Se la tua classe default magento from post action rewrite class indexAction

Quindi, è necessario modificare da

public function indexAction()
{

    $this->loadLayout();
    $this->renderLayout();
}
.

a

 public function indexAction()
    {
        parent::indexAction();

    }
.

Altri suggerimenti

In <frontend> ti viene dimenticato di aggiungere la riga inferiore.

 <layout>
  <updates>
    <contacts>
      <file>contacts.xml</file>
    </contacts>
  </updates>
</layout>
.

Quindi non chiamerà il tuo file contacts.xml.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top