2013-01-15 69 views
0

我已經創建了3個自定義頁面(controller-,php-和tpl-文件)並創建了搜索引擎優化&網址的條目。 所有自定義頁面目前都是重複的,並顯示相同的內容。mod_rewrite /友好的網址與Prestashop 1.5.3

我已經創造了在blocktopmenu.php的自定義頁面的鏈接:

$this->_menu .= '<li><a href="'.$this->context->link->getPageLink('bHome.php').'">Home</a></li>'.PHP_EOL; 
$this->_menu .= '<li><a href="'.$this->context->link->getPageLink('bSamples.php').'">Samples</a></li>'.PHP_EOL; 
$this->_menu .= '<li><a href="'.$this->context->link->getPageLink('start.php').'">Test</a></li>'.PHP_EOL; 

的聯繫正在和網站都正確顯示。

我的問題是,只有一頁友好的URL顯示,我沒有絲毫的想法是什麼問題。

是正常工作被翻譯爲URL如下:

http://localhost/Shop/index.php?controller=start -> http://localhost/Shop/Test 

我的其他兩頁沒有翻譯:

http://localhost/Shop/index.php?controller=bHome 
http://localhost/Shop/index.php?controller=bSamples 

有誰知道這個問題可能是什麼?

+0

我不知道這是否有效果,但使用Prestashop 1.5,您不需要在'getPageLink()'方法中添加'.php'擴展名。您只能使用'bSamples'或'start' – romainberger

+0

感謝您的回答,但不幸的是,這也不起作用。 – user1567896

回答

0

那麼讓我們來看看在功能getPageLink:

public function getPageLink($controller, $ssl = false, $id_lang = null, $request = null, $request_url_encode = false) 
{ 
    $controller = Tools::strReplaceFirst('.php', '', $controller); 

    if (!$id_lang) 
     $id_lang = (int)Context::getContext()->language->id; 

    if (!is_array($request)) 
    { 
     // @FIXME html_entity_decode has been added due to '&amp;' => '%3B' ... 
     $request = html_entity_decode($request); 
     if ($request_url_encode) 
      $request = urlencode($request); 
     parse_str($request, $request); 
    } 

    $uri_path = Dispatcher::getInstance()->createUrl($controller, $id_lang, $request); 
    $url = ($ssl && $this->ssl_enable) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true); 
    $url .= __PS_BASE_URI__.$this->getLangLink($id_lang).ltrim($uri_path, '/'); 

    return $url; 
} 

它消除了.php爲@romainberger建議。但情況並非如此。 接下來我們深入Dispatcher類中的createUrl。我不打算給它的所有粘貼在這裏,你還不如挖自己,但:

public function createUrl($route_id, $id_lang = null, array $params = array(), $force_routes = false, $anchor = '') 
{ 
    if (!$id_lang) 
     $id_lang = Context::getContext()->language->id; 

    if (!isset($this->routes[$id_lang][$route_id])) 
    { 
     $query = http_build_query($params, '', '&'); 
     $index_link = $this->use_routes ? '' : 'index.php'; 
     return ($route_id == 'index') ? $index_link.(($query) ? '?'.$query : '') : 'index.php?controller='.$route_id.(($query) ? '&'.$query : '').$anchor; 
    } 

我敢肯定,這是這裏的情況,這意味着在當前語言的路線是不正常配置。