【问题标题】:URL of the home page in Twig / OctoberCMS TemplateTwig / OctoberCMS 模板中主页的 URL
【发布时间】:2015-08-27 00:45:54
【问题描述】:

所以,我的模板代码中有这个:

<div class="col-md-2 col-md-offset-2"><a href="{{ '/' | page }}">HOME</a></div>

它呈现这个:

<div class="col-md-2 col-md-offset-2"><a href="">HOME</a></div>

如何让它呈现主页(根默认页面)的 URL?

【问题讨论】:

    标签: twig octobercms


    【解决方案1】:

    您必须使用文件名(不带扩展名)而不是页面的 URL。

    比如你的页面是index.htm,你应该使用如下代码:

    <div class="col-md-2 col-md-offset-2"><a href="{{ 'index' | page }}">HOME</a></div>
    

    来源:October Markup docs

    对于子目录中的文件,请指定目录。对于当前页面,在 '' 中不使用任何内容。

    【讨论】:

      【解决方案2】:

      在这个用例中,我认为使用|app 过滤器而不是|page 是有意义的。

      <div class="col-md-2 col-md-offset-2"><a href="{{ '/'|app }}">HOME</a></div>
      

      会给你你想要的。如果您最终将您的网站放在子目录中,它也会保护您。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-09
      • 2020-02-27
      • 2023-03-08
      • 1970-01-01
      • 2017-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多