Questions tagged [best-practice]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

Best practice for organizing assets, locally and in S3?

Asset organization "best practice" question: for a new site, I had planned to reuse as many fields as possible between sections. Now I see that means that I'm not able to separate uploads from ...
2
votes
2answers
118 views

Best practice for naming fields shared across entries in CraftCMS

I have a question about best-practice for naming fields; I am creating a craft site for a football club, which include the following: club name (Global) team names player names These are all ...
1
vote
1answer
60 views

Grouping entries by category - most efficient approach

I have come up with the following code to group entries by categories; {% set hotTubs = craft.entries() .section('newHotTubs') .orderBy('price asc') %} {% set hotTubsCats = craft.categories() ....
2
votes
1answer
2k views

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

I'm unclear as to the best way to deploy a Craft CMS 3 site. I'm looking for some best practices and guidance. I'm currently using Rocketeer to deploy the code from my local environment to my staging ...
5
votes
4answers
228 views

What are the best practices for the development setup?

I've started with Craft developing all locally. The struggle for me when working locally was synchronizing the database and the backend assets with coworkers on the same project. In the last project ...
3
votes
1answer
244 views

Scaling channels with 35 locales

Not so much a technical question as a how-to/best practice one, here goes: I'm building out a site that has 3 content-types (channels), a structure and a bunch of singles. The site has 35 locales. ...
6
votes
4answers
359 views

Which is best practice, SET or FOR?

On my home page template I include a couple of extracts from single entries and I'm not sure which is the best/most efficient way to call them. {% for entry in craft.entries.section('information')....
4
votes
1answer
320 views

When to use “if” or “without”?

When is it advisable or prudent to use without rather than a conditional statement to exclude something, eg a set of entries, based on one parameter? For example, say I have real towns and fictional ...
4
votes
1answer
1k views

Best practice for channels and structures

I am wondering if there is a best practice around using channels and structures. When you have a single section you can link to that section by selecting the entry for it. For channels and structures ...
2
votes
1answer
364 views

craft/app: gitignore, or no?

Just looking for pros and cons here, I guess. My gut says to let updates flow through version control, but the part of me that wants to give up web design and become a mountain man says it might be ...
0
votes
0answers
52 views

Error Icon and DRYer Code

I currently have the following code as part of the address form in Craft Commerce. <label class="label" for="{{ modelName }}-firstName">First Name (*)</label> <input ...
12
votes
1answer
2k views

Macros vs Includes

Is there any guidance or pitfalls/benefits of using one over another? I see that includes can be done more or less the same way a Macro can be done (certainly for simple variable changes). An example ...
7
votes
1answer
980 views

One structure vs a structure per section?

I'm new to Craft CMS and I would appreciate some advice re the best approach to take for modelling content. I'm coming from an ExpressionEngine background, where I would typically use one pages ...
2
votes
1answer
948 views

Best way to organise sections and templates

I'm hoping this isn't too broad or long! I have two questions. I'm trying to streamline the organisation of my site. Firstly: Currently, for every section of my website (e.g. website.com/housing , ...
4
votes
1answer
342 views

Many db requests with relationship fields

I have a page with a lot of entries fields. They are awesome but that leads also to a LOT of db requests. Aside from caching are there some best practices to lower db requests on entries fields? For ...
1
vote
1answer
2k views

Modelling flexible content sections and recommendations

A little background first; I'm coming from WordPress, along with the Advanced custom fields (ACF) plugin, so my thinking behind this may not be the best way in Craft. In ACF I usually set up a field ...
1
vote
1answer
165 views

Best practice for adding a title to a channel overview page

I have a Blog where everything is on one template. The entries don't have an own url. {% for entry in craft.entries.section('blog') %} {# everything #} {% endfor %} Now I want to give this page ...
2
votes
1answer
329 views

Linking to specific entries in Twig: How performant is Reference Tags parsing?

I have a small menu of fixed entries that forms a sub-nav on a site. I'm currently using Reference Tag parsing to grab links to these entries: <li><a href="{{ '{entry:3666:url}' | parseRefs ...
3
votes
1answer
797 views

What's best practice for creating an index page for Channels?

If I have a section called "news" with section type "channel" with entries having their own URLs, what is best practice for creating an index for when people site.com/news? Do I just create an index ...
1
vote
1answer
947 views

Enable the user to upload background Image

How do you enable a user to upload a css background Image? Do you write some inline css in the page header with twig markup? Do you write some twig markup inside a css file? Or do you fake a ...
5
votes
2answers
2k views

Populate a record with a model?

In a follow up to my earlier question, I'm focusing on cleaning up my code to keep it incredibly simple. I've moved on from the Controller and Model to the Model and Service. Typically you would have ...
1
vote
1answer
129 views

Is it possible to sort Sections?

I now have 5 Structures that belong together (they are all different parts of our restaurant menu) together with my other structures its all very confusing. So what I want is a way to split up my ----...
1
vote
1answer
273 views

How to access a structure

I'm trying to build a restaurant menu using a structure. The structure looks like that: > Menu-part 1 > Menu-item 1 > Menu-item 2 > Menu-item 3 > Menu-part 2 > Menu-item ...
2
votes
1answer
222 views

What are «Structures»?

I wonder what structures are since everybody writes about it here. But I can only finde one tiny sentence in the official docs: «Used when entries do have an inherent relationship with each other, ...
2
votes
2answers
455 views

What would be the best way to select and display featured entries?

What would be the best way to select and display featured entries? For example, if I want to choose at least 3 entries to feature in a sidebar apart from the main content?
5
votes
2answers
603 views

What would be the best way to build an Ad rotator?

What would be the best way to build an Ad rotator similar to those we usually see around from http://fusionads.net for example. WordPress have a plugin/widget for adding ads: https://wordpress.org/...
2
votes
2answers
207 views

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

I'm trying to build a page similar to the index page of buildwithcraft.com. There you have a page with (visual) sections ("A new kind of flexible", "Ready where you are" and so on). Each one has ...
4
votes
1answer
343 views

How should I include my custom enums class in my plugin?

If I was going to include my custom enums for my plugin, should the include be outside of my plugin class or use the init() method. What is the best way to handle this and are there any pros or cons ...
31
votes
1answer
8k views

What’s the recommended way to set the site URL?

There are multiple ways to set the site URL. What is the recommended way?
-1
votes
3answers
188 views

What's are some best practices for building a site structure with multiple locations?

First time building a site with Craft, but a long time admirer. Just wanted to know the best way to approach an educational site that has many locations, and then have a news section, etc. in each ...
4
votes
2answers
609 views

Populating an RSS feed with full post content?

I'm using Matrix to give loads of flexibility with blog posts, but it means things aren't as simple when it comes to RSS than if just using a single field called Body. How is everyone else dealing ...
4
votes
1answer
947 views

Sections, Categories, and EntryTypes. Which, when?

bit of a 'best practice' question, as I'm very sure there are many ways to do this sort of thing, but... When/how do you decide whether to use a section, category, or entry type to organise your ...
5
votes
1answer
940 views

Should my controllers actions 'return' when rendering templates?

When developing a plugin, I am registering routes to controller actions. Other frameworks, read that as Laravel, typically return the controllers response. public function showProfile($id) { $...
6
votes
1answer
499 views

What are the best-practices for useful logging messages?

I'm currently adding messages to the log when an error occurs in my plugin. Now I'm wondering what such a message should contain, to provide useful information to developers and end-users? . ...
4
votes
1answer
715 views

Is it possible to Filter entry types via the URL?

I'm wondering if it's possible to dynamically filter a section list by entry type based on a url segment? I'm hoping to avoid assigning a category to every entry.
17
votes
1answer
1k views

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

It seems that currently if you want to avoid the main "about" page at the top of an "about" structure having a slug of /about/about/ then the approach people seem to take is to create an About page as ...