Category Archives: CMS

Drupal – Synchronize Translation

We can translate contents/nodes by activating the Content Translation.
Drupal – Content Translation
 

The translated node itself has not relation with the original node except their node ids are mapped. So I can have a price $10 in the English item but $1000 in the Traditional Chinese item. It will be quite difficult to manage when the amount of content is getting more and more. Therefore, i18n provides another feature called Synchronize Translations. Whenever a node is updated, the synchronized fields of all other corresponding nodes are also updated. Continue reading Drupal – Synchronize Translation

Drupal – Content Translation

The i18n module not only helps translating the Drupal website, it also helps user to manage the translations of the contents/nodes. Once you have enabled the Internationalization in the i18n module, the Content Translation is also activated.

1. Edit the content type which you want to enable the translation. Continue reading Drupal – Content Translation

Drupal – Add Configurable Values to 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

Drupal – Show Database Data in Block by SQL

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

Drupal – Customize Block Template File

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>

Continue reading Drupal – Customize Block Template File

Drupal – Create a Block

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

Continue reading Drupal – Create a Block

Drupal – Using Node Reference in View

Sometimes we may want to create mapping in content types. Say, i created an Artist and a Song content types. when i select an artist, i want it to select all the songs which belongs to that artist also. In that case, we need a node reference field in the Artist content type such that every song is mapped to an artist.

So first, create the Song content type with default fields. Then create some songs and fill in the lyrics as node body. Continue reading Drupal – Using Node Reference in View