我在 Magento 中创建 AZ 索引搜索时遇到了一些麻烦。我已经创建了代码,但是,我收到“无效方法...”错误:
str_replace_once(数组 ( [0] => & [1] => ? [2] => 127.0.0.1/mgn-default/electronics/cameras.html ) )
我不太了解PHP,这里的代码用于:
<?php
$search_array = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','ALL');
/*Find if the URL already contains any querystring variable or not */
if (strstr( $this->helper('core/url')->getCurrentUrl(), "&" ))
{
$separator = '&';
}
else
{
$separator = '?';
}
?>
<div>
<p class="view-mode-list-bot">
<?php
$postData = Mage::app()->getRequest()->getParam('alpha');
foreach ($search_array as $search_array_value):
/*Clean the URL*/
if (strstr( $this->helper('core/url')->getCurrentUrl(), "?" ) )
{
$new_Url = $this->str_replace_once('&','?',str_replace("?alpha=".trim($postData['alpha']),'',str_replace($separator."alpha=".trim($postData['alpha']),'',$this->helper('core/url')->getCurrentUrl())));
}
else
{
$new_Url = str_replace("?alpha=".trim($postData['alpha']),'',str_replace($separator."alpha=".trim($postData['alpha']),'',$this->helper('core/url')->getCurrentUrl()));
}
$alphaURL = $new_Url.$separator.'alpha='.$search_array_value;
?>
<a href="<?php echo $alphaURL; ?>" title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?> <?php if($search_array_value == $postData){ echo 'remove_under'; } ?>"><?php echo $search_array_value; ?></a>
<?php endforeach; ?>
</p>
任何建议和帮助将不胜感激,非常感谢。