SearchRecent posts
The Random ToolboxDrupal 7 Setting up variables for use in a template (preprocess and process functions) Rendering Drupal 7 fields (the right way) Linux Secure Copy (scp) command Restrict Free Shipping in Magento Quickbooks Text Connection Ticket Cross-Site Request Forgery (CSRF) jQuery Events: MouseOver / MouseOut vs. MouseEnter / MouseLeave Monthly archive
|
Insert a block programmatically with DrupalBlock is generated by a view$block = module_invoke('views', 'block', 'view', <view_name not quoted: this is The unique identifier of the view>); example: $block = module_invoke('views', 'block', 'view', list_all_providers_cat_map);
print $block['content']; The above does work for Drupal 5 but it doesn;t look like is working for Drupal 6 so you can just embed the view. print views_embed_view('most_read_today', 'block_1'); If you need the title then use $view = views_get_view('most_read_today'); $view->set_display('block_1'); $output = $view->preview(); $title = $view->get_title(); print '<div class="title">' . $title . '</div>'; print $output; User created block$block = module_invoke('block', 'block', 'view', <block id>); example: $block = module_invoke('block', 'block', 'view', 20); print $block['content']; Block is generated by a module$block = module_invoke(<module name>, 'block', 'view', <block id>); example $block = module_invoke('google_admanager', 'block', 'view', 0); print $block['content']; NOTE: How to find the block ID. Please notice that it is the same syntax so to speak because in the case of the user created block the module name is block since it is the block module that creates it. Drupal 7 Views Block<?php $block = module_invoke('views', 'block_view', 'testimonials-block'); print render($block); ?> |