Closed adamglenn closed 5 years ago
Sure, anything is possible. It would make the things more complicated. Where and how would the predefined options be defined? Where would the type of field (text box, drop-down, check-box, etc.) be defined? And you'd probably what this to be available for all types of custom data (page, site, and theme), correct?
Perhaps something like this in config.yml
, and template frontmatter:
custom_site_attributes:
- google_site_verification
type: text
title: "Google site verification"
description: "Paste the code you got from Google Search Console into this box."
- nav_depth
type: select
title: "Navigation Depth"
description: "How many levels deep to you want your main navigation?"
options:
- 1
- 2
- 3
If type
isn't defined, it defaults to text
.
These would be displayed in Page Properties > Custom Data.
@adamjohnson That would seem like a reasonable place to start. I'll see if I can get a little prototype going in the next week or so.
I have a feeling we're going to get into modal hell...
I added title
and description
keys (see comment above). Right now our attributes get printed out (eg: google_site_verification
) without any further instructions or description as to what that particular box does.
Here's how it might look:
Google site verification
Paste the code you got from Google Search Console into this box
<textarea>
You could also put the description into a tooltip (hover over the ?
).
When title
isn't defined, it defaults to the attribute name.
When description
is not defined, don't output anything.
If this is out of scope, ignore me.
@adamjohnson I tweaked your formatting a bit in your code example above.
The implementation of this feature in the prof tech meeting looked pretty sweet. I especially like that you can declare different types of text data.
One thing that would take this to the next level would be to have the ability to configure a text-field for labels/tags so that it can auto-suggest ones that are already in use, similar to what's already on the page/file properties dialogues.
I'm currently running a site that's using page-data to pull in specific image labels and content editors always seem to have a hard time remembering what tags to use. An auto-suggest feature would be extremely helpful in this situation!
This has been implemented:
https://cleanslatecms.wvu.edu/how-to/theme-development/custom-data/options
There's still room for expanded options (like a label
type or image
type). That said, we can discuss those in specific issues. Thanks for your hard work on this, Nathan.
Would it be possible for certain custom data attributes to be in the form of a drop-down menu with predefined options, or as a check box, rather than a text field? That would be really cool.