5

Is it possible to output the path to a given section?

I'm using this to define the section model for the contact page (a single):

{% set contactPage = craft.entries.section('contact') %}

But then, there doesn't seem to be a way to get the url from this model (according to section model page on the Craft website.

It seems this information does exist as on the backend there's a link to the Contact page next to the link to edit the section.

Many thanks.

bravokiloecho
  • 1,583
  • 4
  • 17
  • 22

1 Answers1

6

The url's are always bound to entries. And with your current code, you're getting all entries in the 'contact' section, not the section itself.

But if this is a single, what you want is the url of the entry in the 'contact' section. Try this:

{% set contactPage = craft.entries.section('contact').first() %}
{{ contactPage.getUrl() }}
André Elvan
  • 7,288
  • 22
  • 34