Skip to main content

Articles tagged with "code"

Making the Flag Module's Confirmation form use AJAX

17th Apr 2012

This article discusses how we can use a combination of techniques to take the standard 'Confirmation Form' provided by the Flag module and get it to load in a modal window rather than on its own page. We'll also extend this form slightly to allow the user to include some additional data before clicking 'Confirm'. As an example we'll use the Flag module to create an 'Abuse' flag that will apply to a comment entity - this is intended to allow a user to flag a comment as requiring moderations but before triggering the actions associated with the flag we...

Read more

Render a block programmatically

22nd Mar 2012

This is a real quick one, but so useful! We often want to render a block within content, perhaps as part of a node (maybe in hook_node_view, and then made configurable like a field), but there's no obvious way to do this correctly for any block. Drupal normally renders its blocks per region, so there is no single function to embed a block. I came across this really simple solution by Damien Tournoud in a Drupal core issue, which I feel deserves more exposure:

$block = block_load($module, $delta);
$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
$output = render($render_array);

That's just three...

Read more

Quick tips: Adding an existing project to a sandbox

19th Jul 2011

Most projects start with you trying out something locally, getting it working and then after some initial testing you might then want to publish the project on Sandboxes are a great way to throw up some code and the perfect place to pop random code that others might find useful or a project that you just don't want to maintain. If you go and create one on then you'll get helpful instructions for creating a new git repository and creating a basic module to go in the repository and then pushing that code to's servers. But what...

Read more

Remove tinymce from drupal block edit page when format is set to PHP

20th Sep 2008

Small one this to compliment our other article on removing tinymce from select textareas. This enhancement will hide tinymce from the Drupal block edit screen when the input format is set to PHP. This stops the problem of tinymce stripping the PHP tags from the block edit textarea when you edit your block

The following function goes into your template.php file and will solve the problem of tinymce showing up on a block when the format is set to PHP

function phptemplate_tinymce_theme($init, $textarea_name, $theme_name, $is_running) {
  print $textarea_name;
    //add text areas to disable tinymce for
    case 'log':
Read more