1

complete newbie question here. Craft is so well designed, I could probably work it out, but it seems like this simple info might help others as well.

So here goes, a two part question: 1. Is there a simple list of the types of pages Craft outputs? (like single-entry, single-category, search-results, etc) 2. What are all the variables available to each of those? (single-entry has a variable called 'entry', plus the globals, I think)

Thank you!

1 Answer 1

2

It looks like you're coming from some other system? When I see "single-whatever" I think of WordPress' specific template structure... which may or may not have any meaning in Craft.

Unlike something like WordPress where there's a very specific structure to how you get information and what template determines how it behaves, Craft is a bit more open-ended (and DIY) in that regard and that can lead to some confusion, especially if you try to setup something like a search page and then try to use entry as variable (which won't be defined, unless you define it yourself).

1. Is there a simple list of the types of pages Craft outputs?

Unlike other content management systems, Craft really doesn't have a concept of "page types". One of the great things about Craft (and probably slightly confusing when you first start) is how you reference content throughout the system in the same, simple way.

You probably know that Craft holds your "page" content in what are called Entries. Think of Entries like Pages since they can map to a URL but they don't necessarily have to...

2. What are all the variables available...

Templates more or less work the same throughout. Craft's Globals are available no matter which template you're in, but Craft really allows you to fetch any piece of content (user, asset, tag, entry, etc.) anywhere you need it.

But what I think you're kind of asking about is when you view an entry or category specifically...

If you setup your sections/categories to have a URL/slug that Craft knows about, Craft automatically will populate the entry or category variable for you so you can access things like title, slug, and any custom fields you might also have on that entry or category.

It's basically a shortcut so you don't have to get it yourself and determine what kind of "page" you're on when you're in a template. Plugins can also inject their own variables into the system.

Craft's documentation on routing is a good place to reference on this as well, especially if you're used to another system where a certain file/folder structure is implied. Everything is up to you so your templates can be as messy or clean as you want them to be.

6
  • Thank you for the explanation. That documentation on routing is especially helpful.
    – kr37
    May 26, 2015 at 15:27
  • Could you clarify how to see the variables available on a section index?
    – ponies
    May 5, 2020 at 17:03
  • @ponies: not sure what you mean? Craft doesn't really have any special variables set for the section index like it does for entries or categories. Usually to setup a blog section, for example, a Structure or Single section can "house" that content. May 11, 2020 at 18:46
  • 1
    @RitterKnight I assumed a section id would be available to the index template automagically like the entry. It seemed like a reasonable default.
    – ponies
    May 11, 2020 at 18:58
  • Yeh I wish there was a better way to handle section indexes on the author side. TBH I think Craft keeps the index up to the developer because it doesn't really know what the intentions are for that template. (Do you bring in 10 entries or all 300K for example?) If you bring in the section information, you likely still need to query for the content contained anyway. May 11, 2020 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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