This is a small module that add a very useful feature for menus blocks created with the Menu block module. You can hide some selected links when the block is rendered.

How to use :

  1. Install Menu block module first.
  2. Install Menu block ignored links
  3. Create a menu block
  4. Save it and go back to your block
  5. You will see in the block configuration a new select field called Ignored links
  6. Choose the links to hide, (of course the links must be part of the chosen menu)
  7. Save, and appreciate the magic!

Sandbox

Link : https://drupal.org/sandbox/nightywolf/2236347

Git repo

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/nightywolf/2236347.git menu_block_ignored_links

Manual reviews of other projects

https://www.drupal.org/node/2407219#comment-9652837
https://www.drupal.org/node/2432439#comment-9652249
https://www.drupal.org/node/2431321#comment-9649957
https://www.drupal.org/node/2431493#comment-9651015
https://www.drupal.org/node/2429043#comment-9652135
https://www.drupal.org/node/2389351#comment-9652353
https://www.drupal.org/node/2430497#comment-9653001

CommentFileSizeAuthor
#3 double_quotes_removed.patch1.31 KBbasvanderheijden
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxnightywolf2236347git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then 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.

nabil.sadki’s picture

Issue summary: View changes
Status: Needs work » Needs review

I have applied all PAreview.sh recommendations. Maybe i've missed something else, it's my first contribution to the Drupal community, some guidance by Drupal guru's will be more appreciated!

basvanderheijden’s picture

FileSize
1.31 KB

Nice module, nightywolf!

However, I've noticed that you use double and single quotes interchangeably.
Therefore, I included a patch which replaces all double quotes for single quotes in cases where the latter are unnecessary.

For your info: using double quotes is slower than single quotes. This, because PHP has to substitute variables (i.e. "Hi my name is {$name}" when using double quotes..

Good luck with your module!

nabil.sadki’s picture

Thanks basvanderheijden for the review, you are right. I have applied your patch right now.

Purushothaman Chinnadurai - Drupal Geeks’s picture

Status: Needs review » Needs work

Hi nightywolf,

Upon Manual Review,

1 - Variables that are created in this module which are not deleted while unistalling the module.

/**
 * Implements hook_form_alter().
 */
function menu_block_ignored_links_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    case 'block_admin_configure':
      if ($form['module']['#value'] == 'menu_block') {
        $options = menu_parent_options(menu_get_menus(), array('mlid' => 0));
        $delta = $form['delta']['#value'];
        $ignored_menus['ignored_menus_' . $form['delta']['#value']] = array(
          'title' => t('Ignored menus'),
          '#type' => 'select',
          '#default_value' => variable_get("menu_block_{$delta}_ignored_menus"),

Variables can be deleted using variable_del() on the hook_unistall() in the .install file.

2 - Hook Comments added on custom submit function.

/**
 * Implements hook_block_admin_configure_save().
 */
function menu_block_ignored_links_block_admin_configure_save($form, $form_state) {

I guess that, hook_block_admin_configure_save() is not an hook. Change the comments for the function.

Thanks
Purushothaman C

nabil.sadki’s picture

Status: Needs work » Needs review

Thanks for the review Purushothaman. Your recommandations are now applied in the current revision.

sawtell’s picture

Status: Needs review » Needs work

Hi nightywolf,

I have installed your module and have run into some issues. The steps I took were as follows:
- Create new menu block
- Set the admin name, leave the rest of the options as default
(Note. I do not see the additional option for ignored menus)
- Save the block successfully
- Click configure on the new menu block
At this point I receive a fatal error:
PHP Fatal error: Unsupported operand types in .../includes/form.inc on line 1808

And the following Drupal messages are logged

Warning: Illegal string offset '#tree' in form_builder() (line 1870 of .../includes/form.inc).
Warning: Illegal string offset '#tree' in form_builder() (line 1890 of .../includes/form.inc).
Warning: Illegal string offset '#parents' in form_builder() (line 1890 of .../includes/form.inc).
Notice: Array to string conversion in form_builder() (line 1890 of .../includes/form.inc).
Warning: Illegal string offset '#array_parents' in form_builder() (line 1895 of .../includes/form.inc).
Notice: Array to string conversion in form_builder() (line 1895 of .../includes/form.inc).
Warning: Illegal string offset '#weight' in form_builder() (line 1899 of .../includes/form.inc).
Warning: Illegal string offset '#processed' in form_builder() (line 1795 of .../includes/form.inc).

Disabling menu_block_ignored_links allows me to access the menu block configuration.

Have you seen this before?

P.S.
Your git clone command should be:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/nightywolf/2236347.git menu_block_ignored_links

PA robot’s picture

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

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

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

nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

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

I've fixed errors reported. Also updated code to be accepted in PAreview

nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
MattDanger’s picture

Nice work here. I've reviewed the code and workflow for this mod and don't see any real issues or blockers.

Small nitpick: Fix for formatting of README.txt

nabil.sadki’s picture

Thanks Matt for the review. README.txt formatting is fixed

nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
nabil.sadki’s picture

Issue summary: View changes
Swarnendu-Dutta’s picture

Status: Needs review » Needs work

Hi @nabil.sadki,

Thanks for your contribution.

A much better way to delete variables would be

function menu_block_ignored_links_uninstall() {
	global $conf;
	$module_string = "menu_block_%_ignored_menus";

	db_delete('variable')->condition('name', db_like($module_string), 'LIKE')->execute();
	cache_clear_all('variables', 'cache_bootstrap');

	$conf = array_intersect_key($conf, array_flip(preg_grep("/^{$module_string}.*/", array_keys($conf), PREG_GREP_INVERT)));
}
klausi’s picture

nope, only variable_del() calls should be used to delete variables, which will also take care of cache clears etc.

nabil.sadki’s picture

Status: Needs work » Needs review

Thanks for the reviews. hook_uninstall() is optimised now

Swarnendu-Dutta’s picture

Status: Needs review » Needs work

In reference to Commit 6a24a61 on 7.x-1.x, i think the query will be

$ignored_links_res = db_select('variable', 'v')
    ->fields('v', array('name'))
    ->condition('name', 'menu_block_%_ignored_links', 'LIKE')
    ->execute();

  // Loop through and delete each of the module variables.
  foreach ($ignored_links_res as $ignored_link) {
    variable_del($ignored_link->name);
  }
nabil.sadki’s picture

Status: Needs work » Needs review

@Swarnendu-Dutta: i don't see any problem for using fetchAll() to get the vars, but if we can remove it without problems, it's better of course.
Your code seem to be working like a charm, so i've commited the changes.

Thanks for the comment

Swarnendu-Dutta’s picture

Status: Needs review » Reviewed & tested by the community

Setting this to RTBC...

naveenvalecha’s picture

Automated Review

Best practice issues are followed.

Manual Review

Review of the 7.x-1.x branch (commit f92f29d)

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
No : Does not Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Maybe: Follows the guidelines for project length and complexity.The module has 5 functions but the code is not more than 120 lines.Not added the "PAReview: Single project promote" because after hook_help the code will be of 120 lines.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
  1. hook_help() is mising in module.
  2. Project page needs some improvements.
  3. menu_block_ignored_links_form_alter : The variables names should be menu_block_ignored_links_{delta} it will make a consistency for you with the module name prefix.This need changes at lot of places in the module.One more thing for long term you should use the custom table.you can extend it later as well.
  4. menu_block_ignored_links_form_alter : $ignored_links['ignored_links_' . $form['delta']['#value']]you can use the $delta variable here in place of $form['delta']['#value']
  5. typo at line 70 weare
  6. menu_block_ignored_links_array_insert_after : Add a comment about the $key typecasting to integer.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

I would recommend you, please help to review other project applications to get a review bonus back. This will put you on the high priority list, and you will come under the admin radar :)

nabil.sadki’s picture

@naveenvalecha : thanks for the full review. Here's my reponses :

README.txt/README.md

Fixed

Code long/complex enough for review

I think that with hook_help in place, the count is greater than 120 lines.

Coding style & Drupal API usage

All points are fixed

kscheirer’s picture

Status: Reviewed & tested by the community » Fixed

Non-blocking issues:

  • Your variables are called "menu_block_ignored_links_{$delta}" but the hook_uninstall is looking for the pattern "menu_block_%_ignored_links", which won't match

Thanks for your contribution, nabil.sadki!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

nabil.sadki’s picture

@kscheirer : thanks for the review, and also for the grant. I will take a look on all the links above. I've fixed the uninstall issue also.
@all reviewers : thanks for your precious time!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.