Sunday, May 16, 2010

Working on CustomPage Module in Drupal 6.x

Custom Page:

Custom Page is an advanced theming tool, allowing developers to easily create pages with custom templates and maintain full control over the output.

This module can be downloaded from http://drupal.org/project/custompage.

Once, downloading is done extract and place in your modules folder.

To add a custom page go to Administration > Site building > Custom pages
List of available templates will be listed here. As we did not add any yet, none will be seen.


Click on 'Add a custom page or block', below screen will be seen.


Note: If above screen is not seen, make sure 'Custom Page Admin UI' module is enabled which is bundled with this module.

Type in the Title, URL path and Key attributes for a custom page. "Key" is the name of a template file which you want to assign. For example, if 'test' is given as key and 'test' is given in URL Path, Now when link 'test' is being accessed from site, it looks for test.tpl.php file for the template.
You can disable a page/block during development by unchecking the check box. Only users with 'administer custompage' permission can access the page when it is disabled.

Once you are done with filing in the fields, click on 'Add Component' button. Now page is created succesfully.

Next, we need to create the template file which was given while creating page. In our example key is 'test' so create 'test.tpl.php' in your current themes folder. Components now need to be inserted into the template file.
A node can be inserted into the page using
print custompage_node_tile( $key, $type = '', $teaser_only = FALSE );
where $key can be a node's node id (nid), in which case $type parameter is ignored, or it can be node's title, in which case the node_type needs to be indicated in the second $type parameter. You can insert just a teaser part of the node by passing $teaser_only = TRUE

Similarly views, webforms, Regions, menus can be inserted to the template and theming can be done to make it display as per your wish.

I have added a node with node id '3' by giving
print custompage_node_tile(3, $type = '', $teaser_only = FALSE ); A page with node id 3 is already available in my site.

Clear cache and access the URL 'test'. You can see the content part replaced with the content in the page with node id '3'.



In this way custom pages can be created with already available nodes, views, menus etc with custom theme.

For furthur information http://drupal.org/node/286219 can be accessed.

We help my innocent i'm able to post the article on custom page module in drupal.

No comments:

Post a Comment