Not long a ago, i have 2 posted about rendering Blocks and Views in PHP.
We can render the Drupal 7 block by PHP in another way.
Continue reading Drupal 7 – Render a Block programmatically
Not long a ago, i have 2 posted about rendering Blocks and Views in PHP.
We can render the Drupal 7 block by PHP in another way.
Continue reading Drupal 7 – Render a Block programmatically
We can render a block in PHP as we discussed previously.
Drupal – Render a Block in PHP Code
This time, we want to render a view display by using the views_embed_view(). Continue reading Drupal – Render a View in PHP Code
You can render a block in PHP as follow.
... $block = (object) module_invoke('<module>', 'block', 'view', "<block id>"); print theme('block', $block); ...
In previous posts, we created a custom module implement the hook_block() function.
We haven’t implemented the block configurable values. Let’s do it now.
We want the block to store a number and a string. so we add these 2 fields in the block configuration page. Here is the new custom.module. Continue reading Drupal – Add Configurable Values to Block
Previous related posts:
The above posts show you how to create and customized the content of a block. Sometimes, we may need to show some database data in the block. So we need to write a SQL. For example, i want to show a list of node titles and the corresponding url links of the Song content type.
1. Modify the custom.module Continue reading Drupal – Show Database Data in Block by SQL
In the Drupal template architecture, you can customized a specific block just by creating a .tpl.php file in the theme folder. For example, the block.tpl.php determine all the block layout in your Drupal theme.
We can also override the design layout of the block in our customized module which we created yesterday(Drupal – Create a Block). First we have to create the corresponding .tpl.php for our block. In this case, we need a block-[module-name].tpl.php.
So create the block-custom.tpl.php
<strong>Hello World</strong> <!-- get the block details from the $block variable --> <p>Subject:<?php print $block->subject ?></p> <p>Content:<?php print $block->content ?></p>
You can create your own block and customized its content. Drupal provides the hook_block() function for block creation. We can implement this function in our customized module.
1. Create a customized module by creating the following files.
<drupal_root>/sites/all/modules/custom/custom.info
name = Custom module description = A custom module which create a block core = 6.x