HowTo Create a 'country' profile field

This page describes how to create a 'country' field in your users' profiles, similar to the one on Drupal.org, that lets you easily find users in any country.

  1. Create a new profile field.
  2. Go to the profile settings page (administer > settings > profiles ?q=admin/user/profile)
  3. Select the 'list selection' type of form field.
    • Category (required): It can be a category you already have or a new one. (Suggested: Personal Information)
    • Title (required): Anything is OK. (Suggested: Country)
    • Form name (required): Anything is ok, as long as it is unique. (Suggested: profile_country)
    • Explanation (optional): Usually, country is self explanatory, but you may want to write a note here to your users about this field.
    • Selection options:
      Defining a comprehensive list of sovereign states is a contentious diplomatic and political issue. Several lists exist on the Web:
      • The ISO International Standard list of country names and two-letter country codes (ISO standard 3166-1) is available in English and French in various formats. See http://www.iso.org/iso/country_codes.htm

Show a block depending on node type and node id

The following snippets allow you to configure a block to be shown or hidden depending on node id (nid) or node type. You can modify the arrays in the snippet to match your needs. Just modify and paste the appropriate snippet in the Block Visibility section when configuring a block.

How to use these snippets

  1. Go to your blocks administration section: "Home » Administer » Site building".
  2. Click 'Add block' to add a new block, or click 'Configure' on an existing block.
  3. Under "Page specific visibility settings" select "Show if the following PHP code returns TRUE (PHP-mode, experts only)."
  4. Paste the snippet in the text area just below. (NOTE: Remember to keep the <?php> tags.)

Modifying Arrays:
Node Type Array
$types = array('page' => 1);

Node ID Array
$nodes = array(1, 2);

Show a block based on $nid

The following will show the configured block in:
Example: http://www.example.com/node/1
Example: http://www.example.com/node/2

NOTE: For Drupal 7, replace $node = node_load(array('nid' => $nid)); with $node = node_load($nid) ; in the example code shown on this page.


<?php
// Only show block from types array and nodes array
$match = FALSE;
// Which node types
$types = array('page' => 1);
// Which nodes (by nid)

Insert an image instead of text in a menu item.

Description

To insert an image instead of text in a menu item you may rewrite theme_menu_item_link().

Drupal 6 version

See here for a functional Drupal 6-tested version.

Step 1 of 2

Put this code into your template.php inside your themes directory:

<?php
function phptemplate_menu_item_link($item, $link_item) {
   
/* Allow HTML if the menu text is an image tag: call l() with 7th argument set to TRUE
     * See http://api.drupal.org/api/4.7/function/l
     */
   
if( strpos($item['title'], '<img') === 0) {
      return
l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), NULL, NULL, FALSE, TRUE);
    }
  return
l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array());
}
?>

Here we just look for the menu title starting with the HTML tag <img and if true call l() with the 7th argument set to TRUE. This will allow HTML inside the menu text. See http://api.drupal.org/api/4.7/function/l.

Step 2 of 2

Working with Views

Using the Views module, you can fetch content from the database and present it to the user as lists, posts, galleries, tables, maps, graphs, menu items, blocks, reports, forum posts etc. It provides a graphical interface to a SQL query builder that can access virtually any information in your database and display it in any format. You can also use Views to present related content. For example, you can display a list of users along with links to the content they have created.

Missing color picker on theme configuration page

The theme doesn't support color picker
Not all themes support the color picker. Check the theme's documentation to find out.
Color module is not enabled
Make sure to enable color.module on Administer » Site building » Modules (admin/build/modules).
File download settings
The color picker is incompatible with the Private download method and will only show when the download method is set to Public - files are available using HTTP directly.

Integrating color module

Color.module allows the admin to change the color scheme of a theme. By selecting a palette of colors (either from a set or by hand), you can change the colors of an entire theme.

Pages

Subscribe with RSS Subscribe to RSS - Designers/themers