23 votes
Accepted

Get children from a Structure entry

If you need to get the level 2 children for a specific parent entry, and you have that entry's entry model instance (i.e. you have an entry variable, referring to the parent entry), you can use that ...
Mats Mikkel Rummelhoff's user avatar
14 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) %} ...
Robin Schambach's user avatar
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 ...
Ian DeRanieri's user avatar
9 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}
Kenyon Kowal's 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 ...
Robin Schambach's 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.
Brad Bell's user avatar
  • 67.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 ...
Jeremy Daalder's 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 ...
Mats Mikkel Rummelhoff's user avatar
6 votes
Accepted

URL structure for structure section

If you do this: {parent.uri}/{slug} You should get URLs like this: site.com/parent site.com/parent/child-1 site.com/parent/child-2 Does that make sense?
4midori's user avatar
  • 656
5 votes
Accepted

A Structure section with an entry to a channel index

I like what Matt P wrote in his answer: try to consider how someone [else] will find the logic of the CMS design The other factor you want to consider in information architecture is you only want ...
RitterKnight's user avatar
  • 6,582
5 votes
Accepted

Product Categories, Structures and Channels

Typically, I will create a single for each product "home" page, and then a channel for my products or sub-pages. I will generally use a channel vs. a structure unless I know I want to manually control ...
Damon's user avatar
  • 4,706
5 votes
Accepted

Recommended Structure - One Site with Pages With Totally Different Layouts?

Option 1 is a safe bet. This allows you to have completely separate, editable templates for each chosen year. You can then change the page slug to match the year of that page. You can reuse fields ...
mrtpain's user avatar
  • 176
5 votes

Order/sort a structure section by date too?

This should work {% set entries = craft.entries({ section: 'news', sortOrder: 'postDate desc, lft asc', }) %}
carlcs's user avatar
  • 36.2k
4 votes
Accepted

Parent/child Single sections

Take a look into Entry Types, I'm pretty sure that's a much better way to handle what you're trying to achieve: https://craftcms.com/features/entry-types So you'd have a Structure section (let's ...
Lindsey D's user avatar
  • 24k
4 votes

Parent/child Single sections

Ignoring the obvious "use a Structure" answer, I suppose you could fake a "hierarchy" by placing a child and parent entry field on each of your Single sections and manually assigning entries as ...
Brad Bell's user avatar
  • 67.5k
4 votes
Accepted

Specific template for a structure

I can't answer it clearly, but I did a workaround for something similar. I've loaded the same template for my structure but gave my structure 2 entry-types(overviewPage, detailPage). Both entry ...
Marco Schuler's user avatar
4 votes

Add home page to a structure?

From an IA and content-modelling perspective, putting all your site's "pages" in a Structure is fraught with problems, and, in my opinion, does a terrible disservice to the future-friendly approach ...
James Smith's user avatar
  • 5,189
4 votes

Website structure with Craft

Steven's answer is great and it allows you to do clever things with faceted search and filtering later on. Don't forget that Categories can also make use of custom fields which is helpful if you want ...
Matt P's user avatar
  • 1,538
4 votes

Website structure with Craft

I'd probably have products as a channel and then a product being tied to a category so and then category urls would be something like /products/category
Steven Grant's user avatar
  • 1,855
4 votes

A Structure section with an entry to a channel index

Yes that makes sense. There are many ways to approach this. I always try to consider how someone other than me will find the logic of the CMS design i.e. How easy will they find Craft to actually use ...
Matt P's user avatar
  • 1,538
4 votes

Linking a page in a multilanguage website

You could write a Twig macro to get the localized URL from an entry ID. Import it from _layout.html for example. {% macro urlFromId(entryId) %} {%- set entry = craft.entries.id(entryId).first() %}...
carlcs's user avatar
  • 36.2k
4 votes
Accepted

Are categories the best way to organize Commerce product filters?

Hard to say if they're the 'best' tool, but I don't see anything here you can't do with Craft categories and they seem the logical and built in way to go about it. In essence you simply look at your ...
Jeremy Daalder's user avatar
4 votes
Accepted

Reusing logic to set string variables

I would use macros. A Twig macro is basically a function, that can take arguments and render HTML. Macros can be defined inline (i.e. in the same template where it's used) or in a separate file (...
Mats Mikkel Rummelhoff's user avatar
4 votes
Accepted

How to prevent select user groups from reordering structures

You should be able to ensure that the elements aren't moved by using the structures.onBeforeMoveElement hook in a plugin: public function init() { craft()->on('structures.beforeMoveElement', ...
Mike Pepper's user avatar
  • 4,391
4 votes
Accepted

How to manage different templates for a structure

Your approach looks good to me. There are different ways you can make it happen: If you set up your structure in the CP you can decide how many levels you want to allow for that structure. (By ...
Wolfram Gehring's user avatar
4 votes
Accepted

How can I display second level children only from a specific parent structure item?

yes you can! You may search for a slug craft.entries.slug('slug-of-first-parent'), select the first result .one(), and then the children by .getChildren(). Now you can proceed as you already did and ...
Luke's user avatar
  • 521
3 votes
Accepted

Get structure url

I think you've made this more complicated that it needs to be for yourself. Reading the Craft docs on Outputting the Entry’s Ancestors in a Structure Section it looks like you can use the handle ....
Luke Pearce's user avatar
  • 3,863
3 votes
Accepted

Only fetch structure entries that are first level or sub level that don't have a parent

You can use the hasDescendants() method to filter out any parent entry with children. You have to use an ElementCriteriaModel with .getPrev() and .getNext(). {% set entries = craft.entries.section( '...
Luke Pearce's user avatar
  • 3,863
3 votes

Specific template for a structure

Building off of Marco's first answer: In your case, perhaps the easiest approach is to have a conditional in your Structure's entry template that checks the entry's level property, and includes ...
Mats Mikkel Rummelhoff's user avatar
3 votes
Accepted

Create a "hidden" page within Structure

Well, a custom field actually does sound like the perfect solution. It's easy and consistent to check on all outputs and areas (sitemap/menu's/other navigations).
chris's user avatar
  • 906

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