Channel for Text Used in Templates - Glossary of Terms #10468
Replies: 2 comments 1 reply
-
@BrandonCronk it sounds like entries may fit the bill, but you're just in need of more of a "quick entry" UI? |
Beta Was this translation helpful? Give feedback.
-
That is correct. It was time-consuming to enter over 100 pieces of text with each one as a separate entry. The other drawback of using a channel for these text strings is that there is nothing to stop a user from adding the same text string multiple times. There are 2 reasons to not embed the text strings into your template directly. First, the client or webmaster might want to edit the terms used after focus testing without having to edit each template that uses that term. Secondly, the alternative purpose of having all of the terms in one database is to have consistency in how elements in the design are referred to. So that way all buttons that edit something say "Edit" rather than "Change." For instance, if the client wants to change every reference to a "client" as now a "customer" then you can look through your text strings and change them all. Also, it ensures that each template doesn't use other terms for a client/customer. Having the functionality of looking for duplicates and avoiding duplicates will allow for greater consistency. |
Beta Was this translation helpful? Give feedback.
-
I am working on a project which has a lot of forms, form labels, and buttons that all have text that is needed. I needed to be consistent in the wording as well as give the client the ability to change this descriptive text as needed during focus testing. I wanted to find a way to put only shortcodes or slugs into my templates and have the resulting text come out for the user.
I tried making a channel that just has one text string per entry. I then used the slug in the templates to pull this text. This method was frustrating to add lots of new text to the channel as each text field was its own entry. This made it though so that the entries could be searched.
Ultimately, I decided upon using a global variable set up as a table. I can now add a new row that has 2 columns. One is the shortcode that I use in the templates to pull the text string and the 2nd column is the output text string. For instance "message-add-new" becomes translated in the templates to "Add a Message." I then pre-load the entire table of shortcodes and text strings to store them in an array since each template will use many of these text strings.
The problem with the table solution is that the entries can't be searched and there are no warnings if someone tries to enter the same text twice. Since hard-coding any descriptive text into a template is not something that most developers should be doing, it would be beneficial for many developers to have their descriptive text fields, text on buttons, and many other text fields come from a channel or global variable within Craft.
The ideal functionality of this would be a simple shortcode or slug for each term and then enter either rich text or plain text into each. The terms should be searchable by shortcode/slug or output text. When a user enters a duplicate shortcode/slug it cannot be saved. When a user enters a duplicate output text or somewhat close to the same text, a warning should appear to let the user proceed with the duplicate or decide to not save and use the other entry.
Beta Was this translation helpful? Give feedback.
All reactions