How do i inject/assign a Drupal tpl file into the content value of a block?

My goal is to create a html snippet that will have links and a JavaScript slideshow. I've searched thoroughly elsewhere but cannot come up with a resolution close to my objective.

How would i assign a drupal 6 tpl file to this array value? What function or hook should i call for this?

      $block['subject'] = 'My Custom Block';
      $block['content'] = Render Drupal tpl file here with javascipt and links..

Answers


The easiest way is to create a file named block-block-ID.tpl.php . When ID is the id of a block you are created earlier.

You can clone the file block.tpl.php and rename it. Remember to clean the cache when you do this!

In this new file you can use drupal_add_css and drupal_add_js functions to add CSS and JS files. Finally, of course, you can modify the html of the file.

Regards.


You could create a theme function in a module like this:

function mymodule_theme() {
    return array(
        'myblockthemefunction' => array(
            'template' => 'mytemplate',
            'arguments' => array('some_param' => null)
        );
}

and then call it like:

theme('myblockthemefunction', array('some_param' => 'paramvalue'));

You then put a file called "mytemplate.tpl.php" into the module directory, and whatever is in there (i.e. your links and slideshow) will be executed. The params for the theme() function will be passed to the template in the $variable.


Need Your Help

SQLite query not working with different android versions

android sql sqlite sql-order-by union

The following query works fine with Android 4.3.1 but not with 2.3.7. The result from the latter is ordered by nameA instead of MAX(unix_time). It looks like, that the ORDER BY statement is complet...

How to debug vim mapping overlaps?

vim latex mapping

In general how to debug and solve key bindings overlapping?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.