1

How can I request the url for a channel index page from another page. I got this message asked on twitter towards craft, but they misunderstood my question.

The came back to me using craft.request.getSegment(x), but this will only work if I would like the index page of a channel when I'm on the entry page of this channel.

But how would I get the url for the "news" channel index page, when I'm in the "projects" channel section (either the index or an entry) of the site?

News is an entry-field of projects btw, so that we can show news related to a project on the site.

  • The channel index page or section landing page will be whatever you define it as in the channel's settings. If your channel is news then it will likely be simply <a href='news'>...<a/>. Is there something in your question that I am missing? – Douglas McDonald Nov 12 '14 at 14:31
  • 1
    Thanks for the clarification. However, this seems like a duplicate of your previous question then. Check out that answer and see if it doesn't answer this question also. – Douglas McDonald Nov 12 '14 at 14:55
  • I don't think these questions are related, as the other one is about creating subpages. This question is about requesting the slug from craft when I know the channel name, as these 2 obviously don't have to be related or have the same name. – Martijn B. Nov 13 '14 at 8:14
2

There is no predefined 'index' page for channels. Channels are simply a collection of entries. If you want an index page then you will need to create it: either as a single, as an entry within another structure, or as a stand alone template in your templates directory (i.e. craft/templates/news/index.html or craft/templates/news.html). In any case, the url (or uri) is going to be whatever you have defined it as. (i.e. mysite.com/news/). See craft's routing documentation for more info on how requests are routed.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.