1

I have a Drupal 7 site with a content type that is for adding courses and courses have a field collection that has multiple fields for Date, Venue, Location(Province)

Each course can have 1 or many dates, venues and locations and these get updated, usually by the company offering the course(User managed content). I can update the course content and field collections for them using feeds module but the problem I have is that the old dates are not being overwritten. So we end up with old dates which are no longer relevant plus the new dates.

The question, is there a way to delete the old dates in bulk? I can't seem to get VBO and views to do this. Am I missing a module that would allow me to select all the field collection fields for a particular node and delete all without having to delete them 1 at a time?

  • Are you able to create a view with exactly 1 views result (row) for each of the field collection items to be deleted, and which also includes a column containing the unique ID of such field collection item? – Pierre.Vriens Oct 20 '17 at 14:18
  • I think I may have found a "solution" with a field collection view. The view I created lets us filter by username(so that we can delete for a particular company) and course dates(so that we can filter courses with old dates). I also added a VBO to delete selected field collections. It will delete all fields within the field collections for the selected courses which can work ok more most cases. I created a content view with relationships to the field collections, author and content field of for the field collections attached to my content type(Delta-All is selected). – user3616622 Oct 24 '17 at 10:13
  • Correct me if I'm wrong, but your prior comment does not answer my previous comment (if you'd answer "yes", then it would be a piece of cake to answer your question). However, it seems from your prior comment you found a solution to your own question. If that's the case, consider transforming your comment to an actual answer (and mark that then as accepted). – Pierre.Vriens Oct 24 '17 at 10:27
  • Oh, sorry I kept trying to solve my problem before I read your comment. I don't know what you mean exactly by 1 views result (row) for each of the field collection items... the view I was able to create lists the courses in rows where one course displays multiple times for each field collection instance. So if course A has 10 dates then course A is listed 10 times each displaying a date, venue, location and field collection item ID can be included – user3616622 Oct 24 '17 at 10:38
1

I created a view that lets us filter by username(so that we can delete for a particular company/user) and course dates(so that we can filter courses with selected dates). It will delete all fields within the field collections for the selected courses. Courses display in rows for each date instance, e.g. if a course has many dates then it displays in a new row with each date field collection item.

I created a content view with a relationships to the field collections-field collection items, author and content field of the field collections attached to my content type for which I selected Delta=All).

I then added fields with the course title, date, venue, location and field collection item ID and displayed in a table with the VBO set to delete the selected field collection items for each instance.

I have filter criteria for the content type, username(author)-exposed, and field collection item for the date-exposed so that I can filter by date to delete old items.

I hope I was able to explain the solution that worked for me so that it can at least offer a clue to someone else with a similar problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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