44 votes
Accepted

How can I route a specific entry in a structure section to its own template?

The cleanest way I have found to achieve this is to create a generic template for the structure as well as a custom template for each entry that needs one, ensuring that its path matches the entry's ...
user avatar
  • 6,341
32 votes

Add home page to a structure?

This isn't documented, so it's subject to change: When you set a Single to be the homepage, its slug is automatically set to __home__. If you want your homepage to be part of a Structure, rather ...
user avatar
  • 3,400
25 votes
Accepted

Changed section from Channel to Structure, but can't re-order entries

Have you switched sorting to "Structure"? When you're not sorting by Structure, you won't be able to rearrange the entries.
user avatar
19 votes
Accepted

Get children from a Structure entry

If you need to get the level 2 children for a specific Structure entry, and you have that entry's EntryModel (i.e. you have an entry variable which refers to the Structure entry), you can just use the ...
user avatar
17 votes
Accepted

How do you only show children of "active" parent in a Structure section's nav?

A recursive macro will help you get around the limitations of ifchildren (which P&T will hopefully resolve soon), as follows: {% set mainEntry = craft.entries.slug(craft.request.getSegment(1))....
user avatar
  • 6,341
14 votes
Accepted

Add home page to a structure?

The "this is for the homepage" button available on single sections does two things for you, when you navigate to the home page's URL: it populates the entry variable with the single's entry model it ...
user avatar
  • 35.9k
13 votes
Accepted

What is the best way to create breadcrumbs based on a structure?

Got it! {% if craft.request.segments %} <nav class="breadcrubs"> <div class="container"> <div class="row"> <ol class="breadcrumb"> <...
user avatar
13 votes

How does the Structure section type work?

I don't know if its possible to be much clearer than the official docs on this matter, but basically a Structure is needed if your entries needs to be in a specific order (and you want to manage that ...
user avatar
13 votes
Accepted

How to fetch entries from multiple sections

You can insert an array of different sections instead of a single one to pull entries from multiple sections {% set entries = craft.entries.section(['sectionHandle', 'sectionHandleTwo']).limit(10) %} ...
user avatar
12 votes
Accepted

Would you use a Structure as navigation over multiple sections (channel entries, indexes and singles)?

Structure for "sorting-only" I haven't tried the approach that you are thinking of yet, but your concerns regarding the query count are not that unfounded. You would need to use the relatedTo() ...
user avatar
  • 35.9k
12 votes
Accepted

URL Format of a nested structure with 3 or more layers

Set the Nested Entries URL format to: {parent.uri}/{slug}
user avatar
  • 6,341
12 votes
Accepted

Output children of a structure section in reverse order

The primary parameter you're looking for is lft: craft.entries.section('volumes').order('lft desc')
user avatar
  • 35.9k
11 votes
Accepted

How can I get the count of entries in a structure?

There may be a better option, but off the top of my head, you could do: {% set countParent = craft.entries.slug('oakview-hotel').first() %} {% set count = craft.entries.section('hotelDetails')....
user avatar
10 votes
Accepted

When to choose a Structure over a Channel?

Ordering and Hierarchy are the main benefits but they create a couple of side benefits such as the ability to get the "children" and "parents" of an entry get siblings including next and previous ...
user avatar
9 votes
Accepted

Structure - Add class if element has children

The Methods section on the EntryModel documentation page has a lot of useful things for working with navigation for Structure sections. You can use hasDescendants(): {% if entry.hasDescendants() %}...
user avatar
  • 2,985
9 votes
Accepted

How to handle top-level/index pages in structure sections?

I recently setup a structure which contains (almost) every page of my site. When I set it up, I specified only {slug} as the URL. So far, it's working fantastically! And that's with about 30-40 pages ...
user avatar
  • 23.6k
9 votes
Accepted

One structure vs a structure per section?

TL;DR: Let the content dictate how you model and architect it. If the site is sufficiently small or sufficiently simple, I think either approach is ok. My team has used both approaches, and it really ...
user avatar
8 votes

Output children of a structure section in reverse order

You could try using use the reverse twig filter. {% for entry in craft.entries.section('volumes')|reverse %} ... {% endfor %}
user avatar
8 votes
Accepted

Entry Form - Multiple Entries & Entry Type & Parent

A little bit late but here it is. Go to https://pluginfactory.io/ and create a plugin, you need at least 1 Controller but you can leave the Name value blank to create a controller with the same Name ...
user avatar
8 votes

Nested Entries in Craft 3

I kind of found a work around, but doesn't seem like it's the correct way to be doing this. {parent.uri ? parent.uri : 'static'}/{slug}
user avatar
7 votes
Accepted

How do you page through entries in a structure?

Craft provides many helpful methods to traverse structure sections and your use case is no exception. Instead of using .getPrev() or .getNext(), try .getPrevSibling() or .getNextSibling() (or their ...
user avatar
7 votes
Accepted

How would I list all entries regardless of section or structure?

Actually your code should work just fine. But by default only 100 entries are fetched, maybe you need to increase the limit: {% set entries = craft.entries.section().limit(null) %} But if you just ...
user avatar
  • 8,326
7 votes

Set Default Entry Types for elements in a Structure Section

I'm not sure if you can set a default entry type within Craft. But a reasonably workaround would be to go to Settings > Sections, then click 'Edit entry types' for the section you need to apply this ...
user avatar
  • 3,604
7 votes

Get structure top ancestor

getAncestors() gets all entries that are ancestors. Since you're looping through them what rootEntry is set to last time through is the closest ancestor. You can avoid the loop and just get the first ...
user avatar
  • 2,985
7 votes
Accepted

Move entry from one structure to another with parenting

That’s a little more complicated, and at that point you’re going to be best off writing your own PHP code to do it. Craft has a bootstrap file that makes it very easy to write custom PHP code without ...
user avatar
7 votes

How to use a Structure including a homepage

You can place your homepage entry in a Structure by setting its slug to __home__. Doing so causes the entry to answer for the / (empty) URI, and it even places the little "home" icon in place of the ...
user avatar
  • 3,400
7 votes
Accepted

Title of the current parent structure

If you are trying to get the top most parent entry of a child entry in a structure, you can use ancestorOf. {% set parent = craft.entries.ancestorOf(entry).level(1).first() %} <h1>{{parent....
user avatar
7 votes
Accepted

Eager Loading a Structure and descendants

Craft 2.6.2789 added this feature, which is seems you've reverse engineered. :) It is now possible to eager-load Structure entries' and categories' descendants using the 'descendants' handle.
user avatar
  • 66.5k
7 votes
Accepted

Ordering of products?

Product types are really all about data concerns - so if the data you're storing for your canines/equines (hereafter known as dogs and horses to save some typing ;) ) - is the same, then you're right ...
user avatar
7 votes

Best practice for channels and structures

You basically have two options for creating a "listing" or "archive" view for your Channel or Structure sections. The first option is to create a Single. This is in many cases appropriate, e.g. if ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible