Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Let's say I have created a block with some Full HTML (Facebook Feed) text inside. How can I commit the block and its text content into my Git repository, so my co-workers can pull it?

share|improve this question
how is this question related to Drupal? – Aboodred1 May 21 at 13:09
Because the block is in Drupal?! Or what do you try to suggest? – koivo May 21 at 13:11
Drupal blocks store its html/text into database, why you need git for? – Aboodred1 May 21 at 13:12
7  
@Aboodred1 This is definitely a Drupal issue (a pretty common one actually). There's an entire Drupal 8 initiative dedicated to solving the general problem of config management. This is about as relevant as it gets :) – Clive May 21 at 13:16
1  
Storage engine is irrelevant - "how to export * from Drupal?" for me is definitely a Drupal question. – Mołot May 21 at 13:17
show 2 more comments

3 Answers

up vote 7 down vote accepted

Turn it into a Feature. Bad thing is, it does not work on built-in custom blocks, so you need to use Boxes to get it work.

That way, you can export block as a module, and modules are text files, so GIT accepts them with it's full support.

Then, there is Features to Git module. It claims:

Features to Git allows trusted users to write features directly to disk, commit them to git and push them to a remote. This makes it possible for site builders to be able to manage features in git without having to get their hands dirty on the command line.

share|improve this answer
+1 for using Boxes-- this works, although from my experience it's a bit of a pain (e.g., if you need translations, you also have to add i18n boxes module). – Patrick Kenny May 21 at 13:33
1  
Everything have it's ups and downs. Built-in blocks needs Block languages module too! I don't claim boxes are easy. I'm not going to claim my answer is best. But from my experience it is an answer (except the Features to Git, it's from Google, not experience). – Mołot May 21 at 13:48
Uhhh Thank you very much!!! That worked like a charm!!! 1. I installed and activated Boxes 2. I created a Box (Structure >> Blocks >> Add Box) and inserted my HTML text (plus set the text format to Full HTML) 3. I created a Feature with the module and the box inside (worked like a charm, box appeared immediately) 4. pushed it into the repo and that's it My co-worker pulled it, acivated it and put everything in the right place again. – koivo May 21 at 14:49

Create a module for that block using the Features module and then commit that module on to the GIT repository of yours.

For more information you could read the README.txt of feature module from.

share|improve this answer

Why not override the block with the relevant block.tpl.php template file. In that way you can easily manage the block contents using Git. The drawback is of course that the block can't be managed in the Drupal admin UI, but it can also be a plus if users with edit block permission are not supposed to edit it. So it all depends.

share|improve this answer
I worked on a site that used this approach. Bad, bad idea. Many hours wasted on looking "where this string came from?". On small sites, under hundred blocks / thousand nodes it might even work. On large ones it's a suicide. – Mołot Jun 11 at 12:46
I merely proposed an alternative working answer to the question. Never claimed it was the best solution. You had already provided the better solution. – enzipher Jun 12 at 8:15
And I just wanted to warn people about problems with this approach I experienced. – Mołot Jun 12 at 8:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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