Send context or arguments to a view in MD?

damien's picture
damien
Sun, 07/14/2013 - 17:07
#1
Send context or arguments to a view in MD?

Hi everybody,

Is there any way to send an argument or define a context when embedding a view in mega menu?

Thank you,
Damien.

damien's picture
damien
Thu, 07/18/2013 - 10:53

Ok i manged to do it, it's a quick patch so needs to be upgraded and enhanced!

1 - In /templates/admin/megamenu_item_admin.tpl.php change the line 6 to
block_id;?>" type="text" class="setting" value="type=block&title=<?php print $item->title;?>&argument=<?php print $item->argument; ?>&block_id=<?php print $item->block_id;?>&block_module=<?php print $item->block_module;?>" />

2- in /templates/meun/theme.inc, replace:

$block_content = module_invoke($block->block_module, 'block_view', $block->block_id);

to

if($block->block_module=='views'){
$viewParams = explode('-', $block->block_id);
$arguments = explode(',', $block->argument);
$view = views_get_view($viewParams[0]);
$block_content['content'] = $view->preview($viewParams[1],$arguments);
}else{
$block_content = module_invoke($block->block_module, 'block_view', $block->block_id);
}

3- then change the argument parameter in text input field on tab edit item (paramater argument), you can use multiple arguments using , (4,2..)

Neo's picture
Neo
Mon, 07/22/2013 - 06:31

Thank you. This is great!

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.