Friday, December 31, 2010

How many Drupal sites are there in the world?


How do you find "all" the Drupal sites that Google knows about?
A post on drupal.org suggests Add New Comment, but that wont be entirely accurate. So far I have come up with a search that lists all sites with a User Account page on user/login:
intitle:"User account" inurl:"user/login"
Or you can use this link to search for drupal sites in Google.
I am aware this only lists sites with user login linked to somewhere and not blocked by Robots.txt.
I have also seen suggestions that looking for a CSS file might work, however with Drupal's CSS aggregation, this could be difficult.
Please share any alternatives, my search above (currently) shows around 2,620,000  (on Google UK). How can we make this better?

Wednesday, December 22, 2010

How to display sub menus (children) of primary links in drupal?

Step 1 : Since we'll be using php codes in a block to display menu, the first thing to do is to enable the PHP Filter under modules.
Step 2 : Go to administer->block->add block and create a new block. Add a description (i use submenu). Choose PHP Code as the filter and paste the code below in the body textarea.

<?php
$menuItems = menu_tree_page_data('primary-links'); 

foreach($menuItems as $key => $m) {
      //check current active menu
   if ($m['link']['in_active_trail'] && $menuItems [$key]['below']) {
       $menu = menu_tree_output($menuItems [$key]['below']);
   }  
}

//print the menu
print $menu;
?>
 
Make sure you include the php delimiters in your code. Press save.
Step 3 : Place your block in a region you want. and that's it. next time you select a menu item in the primary links, the children menu items will show in this block.
You can use active-trail to style the selected menu item.

Alternatively, you may use Menu Block module which can do the same without writing a single line of code. Let me know if you need any guidence.