Is there a way I can use the same field in more than one channel without purchasing an add-on? I have an {image_description} field that I'd like to use in more than one channel. Any work-arounds?
3 Answers
Personally I would create a different field in each as sharing fields across channels has in the past caused me a number of issues when unforseen changes need to be made to the site.
I'd perhaps then use a naming system for my fields - something like;
{channelA_shortname_image_description}
{channelB_shortname_image_description}
e.g. your fieldnames might be (assuming you had channels "people" and "products")
{people_image_description}
{products_image_description}
Then if the issue is that you wish to use the same template code regardless of which channel you're using then you can do something like
{{channel_short_name}_image_description}
The {channel_short_name} would be dynamically replaced with the shortname of the channel you are accessing with your channel entries tag pair.
-
Have to admit that I am pretty sure I've done this in the past but I'm working on something at the moment and it isn't working. I haven't given it my full attention yet but thought it only fair to hold my hands up if this is an incorrect answer. Have you got this technique to work?– foamcowCommented Jan 17, 2013 at 12:20
I don't mean to be presumptuous, but you do know that you can assign the same field group to multiple channels, yes? That is the only way to use the same field in more than one channel.
Some people like to make one single field group that includes fields for their whole site, assign that same group to all channels, and then simply hide the unnecessary fields using publish layouts channel by channel.
In the grand scheme of things, it's advisable to simply use such a field in each field group that requires it, since add-ons that would give you the ability to place a single custom field into multiple field groups (thinking back to the gypsy days) can complicate ongoing support and in particular your upgrade path in the future. There are ways to make that considerably easier to handle though. The excellent Field Editor add-on gives you the ability to mass-edit fields for a given field group as well as clone a field from one field group to another - so you set it up once just the way you like it, then clone it to all other field groups that require it.