Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v3 - Add Twigfield integration for fields that render as object temp… #12120

Open
wants to merge 1 commit into
base: 5.x
Choose a base branch
from

Conversation

khalwat
Copy link
Contributor

@khalwat khalwat commented Oct 13, 2022

This PR is for Craft CMS v3

This PR adds integration with craft-twigfield to provide a Twig editor for fields in Craft CMS that are rendered as Twig object templates.

Description

Autocomplete is provided for:

  • Twig syntax
  • Twig filters, functions, and tags
  • The Craft API, and any installed plugins
  • Section layout shorthand syntax (e.g.: {title}

It is provided in 3 places:

Editing Sections

In the Site Settings table field:

Screen.Recording.2022-10-13.at.2.57.28.PM.mov

Editing Entry Types

In the Title Format field:

Screen.Recording.2022-10-13.at.2.55.49.PM.mov

Assets field settings

In the Default Upload Location, ** Asset Location**, & Allow Sub-folders fields:

Untitled.mov

@khalwat khalwat requested a review from a team as a code owner October 13, 2022 19:48
@khalwat
Copy link
Contributor Author

khalwat commented Oct 17, 2022

I realize that since this is in the CP, P&T may have stringent requirements about the look & feel. @engram-design for example pointed out that he didn't like the Twig logo in the field, for example.

I do think that there should be some kind of visual indicator baked into the field to let people know "hey, you can put any Twig here you want!". The current Craft CP is a little ambiguous in its description of these fields, leading some people to believe that only shorthand {title} type expressions are allowed.

My thought process was that I should use the actual Twig logo, even though I don't like how it looks. To me, it looks like creepy blades of grass, but it is their official logo. If I was listing Craft CMS on a web page, even if I didn't like the Craft CMS logo, probably I use should that rather than inventing my own logo.

However, the idea of a less obtrusive {{}} or {{ for a field indicator or such is something I'm perfectly open to. I just want it to look the same everywhere a Twigfield is used, so people know what to expect from that field. I think using just {} isn't really an indicator that it's Twig, and may confuse people into thinking it's only for the shorthand {title} syntax.

Also, things like the font size, field background, etc. are all customizable via Twigfield on a per-field basis, so wouldn't require any core changes to do them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant