The Block Inject Module Provides an Input Filter that you can add to any of your Input Formats. Once enabled, the filter allows you to inject (insert) any Custom Block into the content at the end of a predefined number of paragraph.

More Details and Installation and configuration instructions at @ http://drupal.org/sandbox/saitanay/1859810

Repo: git.drupal.org:sandbox/saitanay/1859810.git

Auto Review: http://ventral.org/pareview/httpgitdrupalorgsandboxsaitanay1859810git

I understand that this project may not qualify for GIT access (may be bcoz its small with just 140 lines of code), however if the project is deemed useful, please promote it to a "full project" status without granting me GIT access

Comments

rameshbabu.g’s picture

Hi Tanay,

It's a very nice thought ..I am very exiting to get the custom block anywhere in the body field

But here we can achieve this by
1. Enabling PHP filter and writing some code like

$block = block_load('module_name', 'Block_id');      
$output = drupal_render(_block_get_renderable_array(_block_render_blocks(array($block))));        
print $output;

OR
2. Using the below module
http://drupal.org/project/insert_block
It will give one filter for us and then you have to enter code like
[block:name of module=delta of block]

So just I wanted to know, how it is useful rather than the above methods..

Thanks,
Ramesh Babu G.

saitanay’s picture

Hi Ramesh,

Reg (1)
Enabling PHP filters is always a bad idea as it has many security implications involved. When you have a content team, you can not delegate the access of using PHP filter to your content team, which will pose a big security threat

Reg (2)
Firsty, the mentioned module could be used when you want to show your block in a page or two. But on a content-heavy site, you can not edit every node to insert the block. "Block Inject Filter", if configured once, will insert the block in every content that uses the mentioned Input format!

Best
Tanay

dasRicardo’s picture

Hello,

first, sorry for my bad english. I'm not a native speaker.

I has tested the module and i get an error:

Notice: Undefined variable: options in _block_inject_filter_filter_settings() (line 99 of /home/das_ricardo/apache/www/sandbox/site/sites/all/modules/reviews/block_inject_filter/block_inject_filter.module).

The problem is that you do this here:

  // Query to get list of all custom Blocks.
  $query = db_select('block_custom', 'bc');
  $query->fields('bc', array('bid', 'info'));
  $result = $query->execute();
  foreach ($result as $record) {
    $options[$record->bid] = $record->info;
  }

It's never a good idea to declare a variable inside a block that maybe not execute if you want to use it outside the block. In your case if the system have no custom blocks you never create the options variable.

You can handle this error in this way:

  $options = array();
  // Query to get list of all custom Blocks.
  $query = db_select('block_custom', 'bc');
  $query->fields('bc', array('bid', 'info'));
  $result = $query->execute();
  foreach ($result as $record) {
    $options[$record->bid] = $record->info;
  }

Another thing is, you have a master branch but for drupal.org u need only branches like this: 7.x-1.x. So should be remove the master branch. You can read it here

dasRicardo’s picture

Status: Needs review » Needs work

Please check watchdog,

Notice: Undefined variable: body in _block_inject_filter_filter_process() (line 68 of /home/das_ricardo/apache/www/sandbox/site/sites/all/modules/reviews/block_inject_filter/block_inject_filter.module).

It seams the same probem if no block in the system no body variable is defined.

mschudders’s picture

1. Basic application checks

1.1 Ensure your application contains a repository and project page link.
Ok

1.2 Ensure your project is not a duplication.

Seems ok.

1.3 Ensure you don't have multiple applications.
You also have " Comment Limit by Role " please close one of these because only one project needs to be review.

2. Basic repository checks

2.1 Ensure the repository actually contains code.
ok but remove the master branch and put 1.x as the default branch please

2.2 Ensure you are working in a version specific branch.

ok but master branch is still there remove it please.

2.3 Ensure your project contains a minimum of handwritten code.
OK

3. Security Review

3.1 Ensure the project does not contain any security issues.

- Php filters are not that nice.
- This gets executed on every node where you have the same input format this is not that handy =:(
- If the users enabled this but has not selected any options I guess you will receive errors
- For the rest it looks ok

4. Licensing checks

4.1 Ensure the repository does not contain a ‘LICENSE.txt’ file.
ok
4.2 Ensure the repository does not contain any 3rd party (non-GPL) code.
ok
5. Documentation checks

5.1 Ensure the project page contains detailed information.

Ok. (Maybe use real headings h2 h3 ?)

5.2 Ensure the repository contains a detailed README.txt.
ok

6. Coding standards and style

6.1 Run an automated review and ensure there are no major issues.
See above = NOT ok.(master branch)

7. API and best practices Review
ok

saitanay’s picture

Status: Needs work » Needs review

Thanks for the reviews.

as suggested in #3, initialized $options outside the condition

Reg #4
=>Application "Comment Limit By Role" as the attempt to contact the maintainer of "Comment Limit" Module failed
=>Set default branch as specified,. removed master branch

tanzeel’s picture

Status: Needs review » Needs work

Overall module looks good and there is no show blocker.

Moreover, "execution on each page having this filter" can be minimized by using check at top of _block_inject_filter_filter_process function something like:

if($which_block){
// execute all the code
} else {
return $text;
}

Query execution at line 35 can be moved under the condition at line 66 to avoid it being executed all the time.

I have one suggestion in my mind which can extend this module to better use.
- User "exclude pages" option so that admin/user can have better control to display.

saitanay’s picture

Status: Needs work » Needs review

hi Tanzeel,

Reg //"execution on each page having this filter" can be minimized by using check at top of _block_inject_filter_filter_process function
you seem to haven't got an understanding of filters yet,.

Filters are not specific to just blocks,.

Filters are applicable to node content, custom blocks, comments, anything on the site which uses Output format.

Can you justify what advantage you see in adding the piece of code mentioned in comment #7,.

Reg //Query execution at line 35 can be moved under the condition at line 66 to avoid it being executed all the time.
Makes sense, thanks for the suggestion, implemented it,.

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

tanzeel’s picture

Hi,

Code mentioned in comment #7 doesn't create any difference, i got your point. That was my bad.

Module seems ok to me. Let's wait for final review by authenticated persons.

rameshbabu.g’s picture

Status: Needs review » Reviewed & tested by the community

Hi,
looks to be working fine

kscheirer’s picture

Title: Block Inject Filter » [D7] Block Inject Filter
Status: Reviewed & tested by the community » Needs work

Well, initially I wanted to argue this is a duplication too, but after reading the comments this does seem like a unique solution.

I would like to see this point removed:

ENSURE YOUR INJECTED BLOCK HAS A DIFFERENT INPUT FORMAT, ELSE THE DISPLAY
COULD GO INTO A LOOP WITH THE MODULE TRYING TO INJECT THE BLOCK AGAIN
INTO THE INJECTED BLOCK!

Is there a way to avoid this? You could check the input format of the block content you were injecting. Or maybe use a static variable so you can count the number of executions and avoid an infinite loop.

----
Top Shelf Modules - Enterprise modules from the community for the community.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application (see also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

Issue summary: View changes

More Details and Installation and configuration instructions at