Overriding $options = array( '' => '-- Select --' ); per block
hankpalan.com - March 7, 2009 - 03:51
| Project: | Quickmenu |
| Version: | 6.x-1.4 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Ideally I would like to override individual blocks to say "By type", "By Color" etc. Instead of --Select-- when nothing is selected.
I'm not quite up to par with overriding functions in the templete.php file.
Can anybody help me?

#1
You can override this 'select' drop down options by using phptemplate_select() in template.php. The quickmenu uses the 'block-id' as a reference in this dropdowns. So you can make a switch case based on block-ids and override the null element by 'Color', 'Type' etc..
#2
nagarajanl I have this exact same issue. However, my PHP skills are puny.
I understand conceptually what you are saying about overriding the null element of the block-ids of the menus in template.php. Or at least I think I do. But when I go into my current theme's template.php file, I don't see a reference to the block-id.
Would it go inside here?:
/**
* Override or insert variables into the block templates.
*
* @param $vars
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("block" in this case.)
*/
function zen_preprocess_block(&$vars, $hook) {
$block = $vars['block'];
// Special classes for blocks.
$classes = array('block');
$classes[] = 'block-' . $block->module;
$classes[] = 'region-' . $vars['block_zebra'];
$classes[] = $vars['zebra'];
$classes[] = 'region-count-' . $vars['block_id'];
$classes[] = 'count-' . $vars['id'];
$vars['edit_links_array'] = array();
$vars['edit_links'] = '';
if (theme_get_setting('zen_block_editing') && user_access('administer blocks')) {
include_once './' . drupal_get_path('theme', 'zen') . '/template.block-editing.inc';
zen_preprocess_block_editing($vars, $hook);
$classes[] = 'with-block-editing';
}
// Render block classes.
$vars['classes'] = implode(' ', $classes);
}
/**
There is a field to Override the default title for the block in my 'QUICK MENU: Availability' block
It says:
"Override the default title for the block. Use to display no title, or leave blank to use the default block title."
I wish there was a way to specify the use of the title in the drop down menu. I guess this is more of a feature request.
Thanks!
#3
Ok I'm rather stuck. Here is what I have so far:
function phptemplate_select() {if ($block_id = 'menu-genre') {
$options = array( '' => '-> By Genre' );
}
else {
$options = array( '' => '-- Select --' );
}
return $output;
}
I thought I knew what I'm doing but by the looks of it I'm in over my head. I have scoured the net but in reality my php skills are lacking.
#4
EUREKA! I got it. Hopefully this will help someone else.
Open quickmenu.module in a text editor
Remove the line:
$options = array( '' => '-- Select --' );
The module will now default to using the first item in the menu list as the title.
(Wish this was documented somewhere.)
#5
Great, thanks for this solution!