2

I have channels sharing the same field group and am thinking about re-assigning them to different groups because they will develop in different directions (= different fields needed). Is this possible and what would be the best approach? Thanks a lot for suggestions!

1 Answer 1

2

If you've already got a lot of entries published in any of these channels I'd recommend not changing the field group for those channels. The reason being as soon as you go to edit one of your existing entries you will not see the custom fields where you data was stored and as soon as you resave the entry you will lose the data that was stored in the custom fields in the old field group.

So instead just add any new fields to the existing field group to accommodate the different directions your channels are headed in. Then use Publish Layouts on a per-channel basis to hide any irrelevant fields.


If you really need to change the field groups and you have a lot of entries you can migrate the existing field data to new the new fields. You'd need to create analogous custom fields in your new field group and then use SQL to copy the data over to the new fields in exp_channel_data.

Here is some SQL to use as a starting point:

UPDATE exp_channel_data
SET field_id_X = field_id_Y
WHERE channel_id = Z

X = the new field ID number
Y = the old field ID number
Z = the channel ID for the channel at hand

I recommend using a tool like Sequel Pro to help you inspect the data and run the queries. Make sure you backup your database first!

3
  • Thank you for the fast reply, Alex! Will look into the number entries, maybe there are channels with just few entries that can easily be copied. If not, I have found the following queries for duplicating the table: "CREATE TABLE new_table_name LIKE old_table_name;" and then "INSERT INTO new_table_name SELECT * FROM old_table_name;" Can you confirm that these should work (very limited MySQL knowledge here). I had thought about extending the fieldset to accommodate for all channels but different sets seemed cleaner (and maybe faster as well)?
    – Wolfram
    Dec 4, 2013 at 18:52
  • You do not want to be creating any new tables. I will update my answer with sample SQL. Unless your fields are very different between channels then sharing one field group and using publish layouts is less work to set up in my opinion.
    – Alex Kendrick
    Dec 4, 2013 at 19:23
  • Thanks again for your time and advice, Alex! Out of curiosity, I think I will try my luck with Sequel Pro and copying the fields contents. If it doesn´t work out, I´ll take the recommended road of extending the field group with the backed up DB.
    – Wolfram
    Dec 4, 2013 at 23:05

Your Answer

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

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