【问题标题】:Where to find the select html tag for countries on the account create page in Magento 1.9.0.1在 Magento 1.9.0.1 的帐户创建页面上哪里可以找到国家/地区的选择 html 标记
【发布时间】:2015-09-13 00:05:27
【问题描述】:

我想在客户帐户创建页面中显示国家选择框,所以我使用了以下代码:

<div class="field">
                        <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
                        <div class="input-box">
                            <?php echo $this->getCountryHtmlSelect() ?>
                        </div>
                    </div>

我默认得到它。

但它显示第一个选项值空白,当我选择时它显示空白。所以我想显示select country 文本来代替空白选项值。为此,我需要继承它的页面。

【问题讨论】:

  • 启用模板路径提示。您将获得显示它的文件
  • 我已经启用了它显示路径 /app/design/frontend/rwd/b2btheme/template/inchoo/socialconnect/customer/form 但不是特定选择编码的路径
  • 在模板路径提示中,连同文件、块也一起显示。您的编码将来自这些块之一
  • 我已经检查过但没用
  • 没有人知道getCountryHtmlSelect()的路径???

标签: magento magento-1.9 magento-1.9.1


【解决方案1】:

如果您不使用自定义块,标准块 Mage_Customer_Block_Form_Register 使用从 Mage_Directory_Block_Data 块中选择的国家。

这个块反过来使用 Mage_Core_Block_Html_Select 来创建选择。所以在这里你可以学习如何以正确的方式形成它。

【讨论】:

    【解决方案2】:

    您可以在以下路径找到帐户创建页面的 getCountryHtmlSelect 函数

    \app\code\core\Mage\Directory\Block\Data.php

    【讨论】:

      【解决方案3】:

      如果您没有启用任何国家/地区,则默认情况下存在空白选项值。请在后端启用一个来显示(默认情况下,它将是您的默认商店国家/地区)。您可以将第一个值设置为默认设置的国家/地区 ID。

      这个选择来自哪里:

      /app/code/core/Mage/Directory/Block/Data.php
      

      有功能 公共函数 getCountryHtmlSelect($defValue=null, $name='country_id', $id='country', $title='Country')`

      并且在这个函数中创建了块:

      $html = $this-&gt;getLayout()-&gt;createBlock('core/html_select')

      在它下面你会看到参数并且不幸的是有硬编码的类。 如果您需要:$defValue=null 可以设置为国家 ID 以显示除空白选项以外的其他内容。

      这给你空白选项:

          if (is_null($defValue)) {
              $defValue = $this->getCountryId();
          }
      

      例如,您可以在模板中使用:

      <?php echo $this->getCountryHtmlSelect("PL") ?> // GET POLAND COUNTRY
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-08-08
        • 2017-04-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-18
        • 2018-09-28
        相关资源
        最近更新 更多