You are here

README.txt in Block Inject 7

BLOCK INJECT

--------------------------------------------

The Block Inject module allows for regions to be created and injected in the 
middle of chosen node types.

--------------------------------------------

> Install and enable like usual.

--------------------------------------------

Navigate to admin/structure/block-inject and create your region(s). You can 
assign any number of node types you want the region be injected in the middle
of. 

Then add your blocks to the newly created region(s) and these will appear after 
the middle paragraph of each node of the respective content type if there are 
enough paragraphs (2).

--------------------------------------------

Block Inject also makes available an alter hook that allows you to add or change
the attributes that are applied to the wrapper div surrounding the injected
region. 

Example implementation:

/**
 * Alters injected region attributes.
 *
 * @param array $attributes
 *   Contains the node object currently being injected into (non-alterable) and
 *   the attributes array (alterable) that by default includes the id and class. 
 *   You can add more classes or change the id but also add other types of
 *   attributes if needed.
 *
 *   Additionally, it contains a clearfix boolean with which you can remove the
 *   clearfix div being added after the region.
 */
 
 function hook_block_inject_attributes_alter($attributes) {
   if ($attributes['node']->type == 'article') {
     // Adding a custom class to the region wrapper
     $attributes['attributes']['class'][] = 'article-block-inject';
     // Removing the clearfix that comes after the region wrapper
     $attributes['clearfix'] = false;
   }
 }

File

README.txt
View source
  1. BLOCK INJECT
  2. --------------------------------------------
  3. The Block Inject module allows for regions to be created and injected in the
  4. middle of chosen node types.
  5. --------------------------------------------
  6. > Install and enable like usual.
  7. --------------------------------------------
  8. Navigate to admin/structure/block-inject and create your region(s). You can
  9. assign any number of node types you want the region be injected in the middle
  10. of.
  11. Then add your blocks to the newly created region(s) and these will appear after
  12. the middle paragraph of each node of the respective content type if there are
  13. enough paragraphs (2).
  14. --------------------------------------------
  15. Block Inject also makes available an alter hook that allows you to add or change
  16. the attributes that are applied to the wrapper div surrounding the injected
  17. region.
  18. Example implementation:
  19. /**
  20. * Alters injected region attributes.
  21. *
  22. * @param array $attributes
  23. * Contains the node object currently being injected into (non-alterable) and
  24. * the attributes array (alterable) that by default includes the id and class.
  25. * You can add more classes or change the id but also add other types of
  26. * attributes if needed.
  27. *
  28. * Additionally, it contains a clearfix boolean with which you can remove the
  29. * clearfix div being added after the region.
  30. */
  31. function hook_block_inject_attributes_alter($attributes) {
  32. if ($attributes['node']->type == 'article') {
  33. // Adding a custom class to the region wrapper
  34. $attributes['attributes']['class'][] = 'article-block-inject';
  35. // Removing the clearfix that comes after the region wrapper
  36. $attributes['clearfix'] = false;
  37. }
  38. }