1

I understand the rationale of adding one column per custom field to the craft_content table in the database; but why would this happen for fields that are only used once globally?

Is there a way to define global fields without adding to the entire content table?

Perhaps a better option would be to define a single "Options" matrix field which can be used anywhere, and then use that to store zero-or-more options?

1 Answer 1

1

A field is a field, no matter where you are using it. It doesn't matter to Craft whether you attach your field to a Global Set or a Section (or Users or Assets)... All fields are treated equally.

Your fields can be shared between Element Types, and often are.

3
  • Using an entire column in the content table just for 1 global field seems like overkill to me just to add one site-wide preference. I guess I am looking for an alternative to "Low Variables".
    – Lea Hayes
    Commented Nov 26, 2014 at 10:43
  • Globals actually are a good alternative to Low Variables. No offense, but you may be overthinking the internal data structure that Craft is using to store that field data. I'd recommend reading this question & answer for a little more clarity on why Craft stores field data the way it does. It's vastly more efficient for Craft to use the same data structure and code to store Global values as it does with any other field, and totally worth the tradeoff of an extra database column.
    – Lindsey D
    Commented Nov 26, 2014 at 18:25
  • I think the key thing to understand here is the concept of Element Types. Craft prides itself in treating all element types as "first-class citizens"... this includes Assets, Users, Matrix Blocks, etc. It's one of the reasons (arguably the biggest reason) why Craft is so much better architected than all of its competitors.
    – Lindsey D
    Commented Nov 26, 2014 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.