【问题标题】:Magento: Adding contacts form to footerMagento:将联系人表单添加到页脚
【发布时间】:2014-07-28 14:33:21
【问题描述】:

我对 Magento 很陌生,我正在尝试在自定义 Magento 主题的页脚中呼应内置的联系表单。 它无法正常工作,这是我的代码:

form.phtml 的路径:(app/design/frontend/default/mytheme/template/contacts/form.phtml)

XML (app/design/frontend/default/mytheme/layout/page.xml:

<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
    <block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
        <label>Page Footer</label>
        <action method="setElementClass">
            <value>bottom-container</value>
        </action>
    </block>
    <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
    <block type="page/template_links" name="top.links" as="topLinks"/>
    <block type="contacts/form" name="form" as="form" template="contacts/form.phtml"/>
    //the contact form
    <block type="newsletter/subscribe" name="newsletter" template="newsletter/subscribe.phtml"/>
    <block type="cms/block" name="cms_footer_contact">
        <action method="setBlockId">
            <block_id>contact_info</block_id>
        </action>
    </block>
</block>

php (app/design/frontend/default/mytheme/template/page/html/footer.phtml):

 <div class="footer">
    <div class="col3-set">
        <div class="col-1">
            <div class="footer-links">
                <?php echo $this->getChildHtml('cms_footer_links') ?>
                <?php echo $this->getChildHtml('footer_links') ?>
            </div>
        </div>
        <div class="col-2">
            <h2 class="<footer-title"><?php echo $this->__('Ask us') ?></h2>
            <?php echo $this->getChildHtml('contact-form') ?>
          <?php echo $this->getChildHtml('form') ?> //echoing the form
        </div>
        <div class="col-3">
            <h2 class="footer-title"><?php echo $this->__('Contact Details') ?></h2>
            <div class="footer-contacts">
                <?php
                    if(Mage::getStoreConfig("trego_settings/footer/newsletter", $code)){
                        echo $this->getChildHtml('newsletter');
                    }
                ?>
                <div class="contact-info">
                <?php echo $this->getChildHtml('cms_footer_contact') ?>
                </div>
            </div>
        </div>
    </div>
    <div class="footer-menu">
        <?php echo $this->getChildHtml('topLinks') ?>
        <?php echo $this->getChildHtml('footer_socialIcons'); ?>
        <?php echo $this->getChildHtml('footer_copyrights'); ?>
    </div>
</div>

【问题讨论】:

  • 我对 Magento 也很陌生。但是,当我有一个与 Magento 相关的问题时,我会将其发布在:magento.stackexchange.com - 可能需要更长的时间才能得到答案,但答案通常要好得多。

标签: php xml forms magento footer


【解决方案1】:

使用core/template 作为块类型。因此改变:

<block type="contacts/form" name="form" as="form" template="contacts/form.phtml"/>

<block type="core/template" name="form" as="form" template="contacts/form.phtml"/>

【讨论】:

  • 有什么理由应该使用那个块类型而不是另一个?另一个不再是有效的块类型了吗?
  • 这是 Magento 用于联系表单的块:app/code/core/Mage/Core/Block/Template.php
  • 干杯,这真的做到了!
【解决方案2】:

如果您对about xml code then paste 感到害怕,请查看footer.phtml 中的以下代码

<?php echo $this->getLayout()->createBlock("core/template")->setTemplate("contacts/form.phtml")->toHtml();?>

然后 goto form.phtml 将表单的操作更改为$this-&gt;getUrl('contacts/index/post'); 不需要xml

更多详情http://inchoo.net/ecommerce/magento/contact-form-in-magento/

【讨论】:

    【解决方案3】:

    尝试自己做这件事。你看。 G。联系表格 7 插件,创建您的表格并将 CF7 提供的简码插入到文本小部件中。

    【讨论】:

      猜你喜欢
      • 2019-05-16
      • 2013-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-10
      • 2014-06-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多