Use Drupal Form API to Upload File

How to upload images in drupal 6 form API?

Check the following article will help you easily go through:

Following are some drupal file form validate function

Namesort descending Type Location Description
file_validate_extensions function includes/ Check that the filename ends with an allowed extension. This check is not enforced for the user #1.
file_validate_image_resolution function includes/ If the file is an image verify that its dimensions are within the specified maximum and minimum dimensions. Non-image files will be ignored.
file_validate_is_image function includes/ Check that the file is recognized byimage_get_info() as an image.
file_validate_name_length function includes/ Check for files with names longer than we can store in the database.
file_validate_size function includes/ Check that the file’s size is below certain limits. This check is not enforced for the user #1.

How to theme a form in Drupal6 with Drupal Form API

Drupal provide a Form API to let us make a form. That is a right way to do that.

By default, it create a form element in html like this:

But how to add some custom html or class into it? Continue reading How to theme a form in Drupal6 with Drupal Form API

Drupal get “Warning: MySQL server has gone away”

If you got this error, this article will save you:

Basically it is say the MySQL out of resources. Modify the MySQL configuration as following:

In Windows this file is located by default at C:\Program Files\MySQL\MySQL Server X.Y\my.ini. In Linux this file is located at /etc/my.cnf to set global options, or /usr/local/var/mysql-data-dir/my.cnf to set server-specific options.

Important: Remember to keep backup files before you do anything! You will also have to reload the MySQL service after making changes to these configuration files.

Drupal Template File

There are already have some Drupal core function let us using templates. As the following.  For Drupal 6, Drupal 6 Template Suggestions will help. If you want customise more flexible conditions, have a look on Working with template suggestions .

For Node:

Just use the following file name rules to template drupal:

  1. page.tpl.php (global)
  2. page-front.tpl.php (front page)
  3. page-node-edit.tpl.php (node edit)
  4. page-node-[#].tpl.php (specific node)
  5. page-node.tpl.php (nodes – global)
  6. page-[internal/path].tpl.php (specific path)
  7. page-node-[content type].tpl.php  (specific content type)

If not add the page prefix, like the following, then it will use page prefixed tpl file as their parent template( which already have layout including header and footer  )

  1. node.tpl.php
  2. node-[#].tpl.php
  3. node-[content type].tpl.php

For block:

take a look at this page:

Drupal 7

In Drupal 7 template files are searched in the following order:

  • block–block–[block-id].tpl.php
  • block–[module]–[delta].tpl.php
  • block–[module].tpl.php
  • block–[region].tpl.php
  • block.tpl.php

If the block delta key uses a hyphen, (-), replace this with an underscore (_).

Drupal 7 Template (Theme Hook) Suggestions

Drupal 5 & 6

In Drupal 5 and 6, template files are searched in the following order:

  • block-[module]-[delta].tpl.php
  • block-[module].tpl.php
  • block-[region].tpl.php
  • block.tpl.php

For example, the user login block has a delta of ‘0’. If you put it in the left sidebar, when it’s rendered, PHPTemplate will search for the following templates in descending order:

  • block-user-0.tpl.php
  • block-user.tpl.php
  • block-left.tpl.php
  • block.tpl.php