Hot answers tagged

20 votes

Solution for Matrix-within-Matrix (or More Robust Table Fields)

Rather than trying to store multiple stats together in a single block, another option would be to make a "Stat" (singular) block type, which only holds a single stat, and just have authors create as ...
user avatar
17 votes

Solution for Matrix-within-Matrix (or More Robust Table Fields)

Folks may also want to checkin the Super Table plugin that just came out. It allows you to create table fields that include almost any field type: https://github.com/engram-design/SuperTable Keep in ...
user avatar
14 votes
Accepted

A/B testing - how to in Craft?

You can set a cookie from your template, which assigns visitors to specific groups: Craft 2: (Use the LJ Cookies plugin) {% set testGroup = craft.lj_cookies.get('group') %} {% if not testGroup %} ...
user avatar
11 votes
Accepted

Is there a way to delete all entries?

You could also delete all rows in your craft_elements table, which have type set to Entry (or whatever ElementType you want to delete).
user avatar
  • 8,316
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
Accepted

How can I remove all text content and assets from a duplicated site?

You can delete all of your existing entries and assets by executing this SQL query: DELETE FROM craft_elements WHERE type IN ('Entry', 'Category', 'Tag', 'Asset') All associated content, ...
user avatar
8 votes

Globals versus Singles

The performance aspect is difficult to answer. On every pageload, Craft pulls all your global sets, which can be a performance hit, especially if you have many huge, complex global sets with a lot of ...
user avatar
6 votes

Solution for Matrix-within-Matrix (or More Robust Table Fields)

This question was asked prior to the release of the Neo plugin/field type. I think this would offer a better approach than the SuperTable (which was/is still awesome), just because I think it's easier ...
user avatar
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 ...
user avatar
5 votes

Craft's Content Table

A huge boon to Craft is the ability to re-use fields across all your content – sections, categories, entry types or even users. The field groups are basically only there to make it easier for you to ...
user avatar
5 votes

Craft's Content Table

MySQL has a hard coded limit of 4,096 columns per table, although that can be effectively limited by the data types of columns involved. Matrix fields get their own tables, so they don't count ...
user avatar
  • 66.4k
5 votes

Solution for Matrix-within-Matrix (or More Robust Table Fields)

An alternate solution that might work is to create separate channels for 'stats' and 'quotes', and then use an entries field within your matrix block to add them to the 'stats' and 'quotes' blocks. ...
user avatar
5 votes

Has someone figured out Craft 3 content migrations?

This is a plugin I'm working on to do exactly what you are after. https://m.youtube.com/watch?v=n6ko2PKUqAo&feature=youtu.be The syntax to figure out how to create sections, elements etc is ...
user avatar
5 votes
Accepted

Has someone figured out Craft 3 content migrations?

For now (when the docs are not ready) you look into the craft source how things are saved for example: https://github.com/craftcms/cms/blob/develop/src/controllers/FieldsController.php#L250 Based on ...
user avatar
  • 308
4 votes
Accepted

Creating a related content subpage to a channel entry?

Two ways that this can be done is A) use a structure, or B) use custom routes. Using a Structure with different entry types defined for the various sub-page types would probably be the most ...
user avatar
4 votes
Accepted

How can Craft-generated Content HTML be accessed via an external PHP app?

Your app can load up Craft using its bootstrap.php file: $craft = require 'path/to/craft/app/bootstrap.php'; That file returns a Craft\WebApp instance. From it, you can access all of Craft’s ...
user avatar
4 votes
Accepted

How flexible is tying content to a structure?

Structures simply add an extra bit of sorting and querying. You can look for entries in a structure the same way you look for entries in a channel. The difference is that you can also have parents and ...
user avatar
4 votes

What is the best way to include an Element's content?

I've determined what I think to be the best way to dynamically add Element's field content values to my responses. First off, the reason why field content values are being returned using $element->...
user avatar
  • 81
4 votes

Migrate contents between fields?

I've managed to achieve something which works in the least technical way I can think of. Other solutions might involve migrating data directly within the database, but I figure this is a good starting ...
user avatar
  • 1,538
4 votes

Has someone figured out Craft 3 content migrations?

"I'm just having a hard time figuring out what options there are." The options are virtually limitless. You can put almost anything you want into a safeUp method. Craft 3 is still in beta, and ...
user avatar
  • 23.6k
3 votes
Accepted

What is the max # of version history for any given entry?

There is no set maximum number of versions an entry can have, assuming you have unlimited database space. Take a look at the source code in the EntryRevisionsService for more information: https://...
user avatar
3 votes

Creating and using custom content tables

Okie doke. After bashing my head against the wall THIS is how you create your very own super deluxe content table. Allow me to explain... In your element class you will need to specify the following: ...
user avatar
  • 481
3 votes

Is there a way to delete all entries?

I figured it out somewhat by using the Import plugin, by Bob Olde Hampsink, exporting all my slugs to a csv, then using the delete functionality of the plugin to remove all entries with a slug found ...
user avatar
3 votes
Accepted

Content Modeling for Site Architecture Recommendations

It sounds like you have 3 different general buckets of entries to consider: Streams of similar entries (News section, blogs, etc.) General content pages (100+ of them) Unique/one-off pages (Contact ...
user avatar
3 votes
Accepted

content and fields won't show up on new single

I fixed it... I hadn't assigned a field to the section.
user avatar
  • 186
3 votes

Has someone figured out Craft 3 content migrations?

I've written up an article with some basic examples of content migrations in Craft 3: https://medium.com/@mikethehud/craft-cms-3-content-migration-examples-3a377f6420c3 As others have stated I just ...
user avatar
2 votes

Solution for Matrix-within-Matrix (or More Robust Table Fields)

Maybe this is not the best idea for your exact use case, but what about using a Structure section for your entries with two levels. Top level entries would be your "actual entries" and their child ...
user avatar
  • 35.8k
2 votes
Accepted

Advanced layout: Best way to create a tabbed page with variable content in each tab

This really is a case for nested Matrix fields. It’s something we definitely plan on adding at some point, but that won’t help you here. Looks like you’re using nested Structure entries to accomplish ...
user avatar
2 votes

Updating just a single content field from a plugin

I don't have much experience using tasks, but I often write plugin methods to move data around. Typically, I just use the EntriesService saveEntry or RelationService saveRelation as needed. Here is a ...
user avatar
2 votes
Accepted

Have auto selected categories with new section entry

That functionality doesn't currently exist out-of-the-box (as of 2.5.2752), but it would be possible as a custom development: You'd essentially need to create a clone of the Categories fieldtype, add ...
user avatar
  • 3,390

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