在Magento 1.9.0.1中的帐户创建页面上,可以在哪里找到国家/地区的选择html标记

时间:2015-06-26 06:26:42

标签: magento magento-1.9 magento-1.9.1

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

<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文本代替空白选项值。为此我需要继承它的页面。

3 个答案:

答案 0 :(得分:1)

如果您未启用任何国家/地区,则默认为空白选项值。请求后端中的一个显示(默认情况下将选择,可以是您的默认存储国家/地区)。您可以将第一个值设置为默认设置的国家/地区ID。

此选择来自:

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

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

在这个函数中创建了块:

$html = $this->getLayout()->createBlock('core/html_select')

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

这会给你空白选项:

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

您可以在模板中使用:

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

答案 1 :(得分:0)

如果您没有使用自定义块,标准块Mage_Customer_Block_Form_Register将使用Mage_Directory_Block_Data块中的国家/地区选择。

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

答案 2 :(得分:0)

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

\应用\代码\核心\法师\目录\块\ Data.php