【问题标题】:Page URLs not working页面 URL 不起作用
【发布时间】:2016-07-18 08:33:51
【问题描述】:

我是 10 月份的新手,我正在尝试开发一些主题和插件。

除了页面链接之外一切正常。

例如,博客页面有这个标记:

title = "Novità & Offerte"
url = "/news"
layout = "blog"
is_hidden = 0
meta_title = "News & Offerte"
meta_description = "Scopri tutte le novità."

[blogPosts]
pageNumber = "{{ :page }}"
postsPerPage = 10
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
categoryPage = "news/categorie"
postPage = "news/post"
==
{% component 'blogPosts' %}

我试图从标题部分的静态菜单中调用此页面,但没有结果:它一直重定向到主页。

试过了:

<li><a title="Le novità del nostro negozio" href="{{ 'news'|page }}">Novità</a></li>

<li><a title="Le novità del nostro negozio" href="{{ '/news'|page }}">Novità</a></li>

没有任何作用。我不明白为什么它会正确重定向到博客文章或类别,而不是 10 月份的“正常”页面。

博客使用 Rainlab 博客插件运行。

有人可以帮我解决这个问题吗?

提前致谢!

【问题讨论】:

    标签: octobercms


    【解决方案1】:

    您可以使用URL helper function。例如:

    <a href="{{ url('/news') }}">News</a>
    

    这应该产生类似:

    <a href="http://app.localhost/news">News</a>
    

    【讨论】:

    • 这完全符合预期!谢谢亚历山大!
    【解决方案2】:

    页面过滤器使用页面文件名

    创建到页面的链接

    将您的页面保存在 news.htm 文件中,然后尝试

    href="{{ 'news'|page }}"
    

    或保存在 something.htm 文件中,然后尝试

    href="{{ 'something'|page }}"
    

    OctoberCMS filer |page

    【讨论】:

      【解决方案3】:

      就像 Tomasz P 所说的

      October CMS 使用 |page 过滤器实际上是在寻找文件名。如果您决定更改 url 并保持页面名称相同,那么使用哪个很好。

      Photo of the CMS Page Settings

      所以在这种情况下,我需要使用网站/商店。因为您的链接正在路由到主页或什么都不做可能是因为它找不到正确的文件名。

      <a href="{{ 'site/store'|page }}">Store</a>
      
      I usually stick with standard link usage 
      <a href="/store">Store</a>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-12-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-02-24
        相关资源
        最近更新 更多