Skip to main content
19 votes
Accepted

Macros vs Includes

Fabien Potencier, the main developer of the Twig templating language answered the question like so: Macros: reusable markup across a lot of templates Includes: part of "pages" that are ...
carlcs's user avatar
  • 36.2k
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
8 votes
Accepted

Which is best practice, SET or FOR?

Regardless of the number of elements involved, Craft will return an iterable ElementCriteriaModel whenever you query for content (e.g. via craft.entries, or using relational FieldTypes like Assets, ...
Mats Mikkel Rummelhoff's user avatar
8 votes
Accepted

When to use "if" or "without"?

For your example, you should exclude the fictional towns in the initial query itself rather than filtering them out afterwards: {% set towns = craft.entries.section('towns').townFictional('not 1')....
Mike Pepper's user avatar
  • 4,391
7 votes
Accepted

Get entry associated with current uri

Surprisingly, the Craft docs aren't super clear on this so I'll post a little info. When you set up a Section in the Control Panel, you set the URI Format and Template fields to map to an entry ...
Sam Hernandez'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

Many db requests with relationship fields

This is how relationships work in Craft at the moment. Each relation equals +1 query. If you don't access your relation on an entry the query isn't executed. So by only fetching title and/or id you ...
naboovalley's user avatar
  • 2,844
6 votes

Modelling flexible content sections and recommendations

I'm not familiar with ACF, but if you're looking for blocks-within-blocks, you could use the Neo plugin/fieldType. It allows you to define blocks, and then have nested blocks. It allows for decent ...
Ian DeRanieri's user avatar
6 votes
Accepted

What are the best practices for the development setup?

That's the setup we use here. It's ok, but local development runs slowly because the database is off-site - we'll be moving to an internal database server in the new year because of that. Image ...
Matt Wilcox's user avatar
  • 3,199
6 votes
Accepted

Scaling channels with 35 locales

You could have a single News section that is enabled for each of the locales, and choose which locale each entry should target from their Edit pages. To make it easer on the authors, you can set the ...
Brandon Kelly's user avatar
5 votes

Best practice for naming fields shared across entries in CraftCMS

The job of naming something is sometimes the most difficult part of a project! This is pretty subjective, but even though it seems like those three fields would share the same settings and ...
Steven Thate's user avatar
5 votes
Accepted

Grouping entries by category - most efficient approach

One improvement I think could be made is to fetch only the ID's of your hotTubs entries at the start of your code. You're only using this to get the related categories and fetching ID's is faster than ...
Tom De Smet's user avatar
  • 1,456
5 votes

Which is best practice, SET or FOR?

Both are essentially the same query, the only thing that differs is the WHERE statement. The ID approach will always be the most efficient, since it uses the primary key index, thus finding the result ...
Gustavs's user avatar
  • 406
4 votes

What are the best practices for the development setup?

Matt Wilcox alluded to it in his original comment, but something like Craft-Scripts will really help out with this workflow. You can read more here: Database & Asset Syncing Between Environments ...
andrew.welch's user avatar
  • 11.6k
4 votes

What is the best way to deploy a Craft CMS 3 site?

At the risk of offering a "link answer", the Setting up a New Craft CMS 3 Project has a section on DEPLOYING CRAFT CMS that should be useful to you. I've never heard of Rocketeer, but popular ways to ...
andrew.welch's user avatar
  • 11.6k
2 votes

Which is best practice, SET or FOR?

Working with singles you can use them both. However, the set has the advantage that you can apply multiple filters etc. on it afterwards. Especially handy with more complex designs and when working ...
Jan_dh's user avatar
  • 858
2 votes

craft/app: gitignore, or no?

No. Keep craft/app in your repo. Disclaimer: This is my own personal opinion. The topic comes up with some frequency on Craft Slack, and you will find advocates of both approaches. I fully expect ...
Lindsey D's user avatar
  • 24k
2 votes

What are the best practices for the development setup?

I'd recommend you take a look at the excellent existing threads on this: Git Workflow and Multi Environment - how to approach What's the best practice for handling data migration and organization ...
Shahroze Nawaz's user avatar
2 votes
Accepted

Best practice for naming fields shared across entries in CraftCMS

If the fields can all use the same description and settings (allow multiple lines, text size), you could use the same field (we do). If there's even the slightest chance the description need to be ...
Paul's user avatar
  • 6,338
2 votes

Best Approach to all unique groups of users to edit unique groups of entries in 1 channel

If you're not using Craft's user groups for permissions, the solution you suggest is more or less exactly what sprung to my mind. You could create a Category Group called Permissions (just to keep it ...
Martin Spain's user avatar
  • 1,519
2 votes
Accepted

How to relate a long survey to a user and later query by values

When you're dealing with that many fields it's definitely a non-trivial undertaking but Craft does have all the tools you need to pull it off. Your plan B is probably the most solid option. Make a ...
RitterKnight's user avatar
  • 6,582
1 vote
Accepted

Performance basics? BlogPost+Comments vs. One ever-expanding Matrix Field?

Regarding performance: If you look at the database structure of Craft, you'll see that Matrix content is stored across multiple tables, with each block having its own record, just like entries do. I'...
Evan Warner's user avatar
1 vote

What is the best way to deploy a Craft CMS 3 site?

I guess you're seeing this notice, because of pending migrations after an update. After you deployed the repository, you should make sure that: Run composer install --no-interaction to install ...
Max Strebel's user avatar
1 vote

Best way to organise sections and templates

I would use separate Structure for each content type, instead of having them all in a single structure. Separate structures would allow cleaner 'relationships' between entries. Your template ...
Matt P's user avatar
  • 1,538
1 vote

How do I set up a section for pages with very flexible content?

I've done something similar with custom includes. Make a new section called 'includes' with a matrix to build content and options for background colour, text colour etc. Then from your 'home' page (or ...
dmatthams's user avatar
  • 2,492

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