0
我正在一個網站上工作,需要導航鏈接平滑滾動到主頁上的錨點,導航鏈接鏈接到所有其他頁面上的單獨頁面。我嘗試了各種各樣的策略來達到這一目的無濟於事。以下是我嘗試過的一些方法。Smarty設置基於URL的導航href
網址使用.htaccess
構建。 Home沒有請求URI,因爲它是網站的索引頁面。 PUBLIC_URL
在配置文件中設置。
檢查HTTP_HOST
是否等於PUBLIC_URL
,並且沒有參數正在傳遞給其他頁面。
{if $smarty.server.HTTP_HOST == $smarty.const.PUBLIC_URL && $smarty.server.REQUEST_URI == ''}
<a href="#locations">Our Locations <i class="ti-angle-down"></i></a></span>
{else}
<a href="{$public_url}locations">Our Locations <i class="ti-angle-down"></i></a></span>
{/if}
檢查,如果有任何PARAMS(邏輯上不作爲PUBLIC_URL
工作是一個常數,因此將始終返回false在這種情況下)。
{if $smarty.const.PUBLIC_URL == ''}
<a href="#locations">Our Locations <i class="ti-angle-down"></i></a></span>
{else}
<a href="{$public_url}locations">Our Locations <i class="ti-angle-down"></i></a></span>
{/if}
外出時關閉以正在處理的模板(邏輯上的資產淨值包含在它自己的模板文件不工作)的。
{if $smarty.template == 'home.tpl'}
<a href="#locations">Our Locations <i class="ti-angle-down"></i></a></span>
{else}
<a href="{$public_url}locations">Our Locations <i class="ti-angle-down"></i></a></span>
{/if}
查看是否不存在請求URI。仍然返回false。
{if $smarty.server.REQUEST_URI === ''}
<a href="#locations">Our Locations <i class="ti-angle-down"></i></a></span>
{else}
<a href="{$public_url}locations">Our Locations <i class="ti-angle-down"></i></a></span>
{/if}
我一直停留在此的幾個小時,並已用盡谷歌上搜索我的詢問,SO,和Smarty的論壇。任何方向將不勝感激。