2. CCK Field Formatters

If you want more control, you can lay each field out and give it whatever format you want. For example our first_name field, which does not have multiple values enabled, would be displayed as follows (the [0] means it is the first available value for that field):

<?php print content_format('field_first_name', $field_first_name[0]); ?>

Multiple value fields require a bit of simple php code. You want to scroll through the multiple phone and email fields and print each one surrounded by dd elements. So you code something like this to make sure that all the values get picked up (no need for [0] here because we're going through each field's values one by one):

 <?php foreach ($field_phone as $phone) { ?>
   <dd> <?php print content_format('field_phone', $phone) ?> </dd>
 <?php } ?>

Some fields have more than one formatter available. If you don't specify a format, you will get the default format. For instance, the text module has three formats: 'default', 'plain', and 'trimmed'. The default format uses whatever filter the author selected to display the text. The 'plain' formatter strips all the html tags out of the text, and the 'trimmed' formatter trims the text down to the size specified for a teaser value.

Modules that integrate with CCK

There are a number of modules that integrate with CCK. Some are field modules that allow you to create specific kinds of fields. Others are helper modules that add functionality to CCK. Some modules are considered 'core' components and are packaged with the content module and maintained by the CCK maintainers. Others have been created by other developers. As with all contributed modules, modules created by other developers are not official and may or may not work. The descriptions below will indicate whether the module is a part of the core CCK package.

Views Integration

Date range argument handler

Argument is based on ISO 8601 date duration and time interval standards

See http://en.wikipedia.org/wiki/ISO_8601#Week_dates for definitions of ISO weeks See http://en.wikipedia.org/wiki/ISO_8601#Duration for definitions of ISO duration and time interval

Argument expects a value like 2006-01-01--2006-01-15, or 2006-W24, or @P1W. Separate from and to dates or date and period with a double hyphen (--)

From and to dates in argument are ISO dates, but can be shortened and missing parts will be added. Omitted parts of ISO dates will be assumed to be the first possible (for the from date) or the last possible (for the to date) value in that time period.

The 'to' portion of the argument can be eliminated if it is the same as the 'from' portion Use @ instead of a date to substitute in the current date and time.

Shortcuts are available:

Use periods (P1H, P1D, P1W, P1M, P1Y) to get next hour/day/week/month/year from now Use date before P sign to get next hour/day/week/month/year from that date The ISO standard calls for a separator (--) between a date and the P, but the separator is optional between a start date and a period in this argument to make the result easier to read.

This module does not currently handle the option of using a period with an end date, only a start date followed by a period.

Howto: Make the user profile layout compact (with css only)

Screen Shots:
Before: http://img205.imageshack.us/img205/899/beforedw4.png
After: http://img164.imageshack.us/img164/2630/aftergv7.png

To make the view of the 'user profile' page compact, add the following CSS to the end of your theme's .css file. This is generally better than modifying the profile.css or user.css (or drupal.css in 4.7) directly.

.profile h2.title {
  margin-top:13px;
  border-bottom-width: 1px;
  border-bottom-style: solid;
}

.profile dd {
  min-height:10px;
  margin:5px;
  margin-top:13px;
  margin-left:180px;
  margin-bottom:0px;
  padding:0px;
  width:300px;
  height:auto;
  position: relative;
  border-bottom: 1px dotted #d9d9ff;
}

.profile dt {
  width:180px;
  background-color: #DEE;
  border-bottom: 1px solid white;
  float:none;
  margin-bottom: -30px;
}

Alternate version using a floating dt

.profile h2.title {
  margin-top: 15px;
  border-bottom: 1px solid #777777;
}
.profile dt {
  margin: 0;
  padding: 2px 3px;
  width: 120px;
  background-color: #dee;
  border-bottom: 1px solid white;  
  float:left;
}
.profile dd {
  margin: 0 0 0 130px;
  padding: 2px 3px;
  border-bottom: 1px dotted #d9d9ff;
}

Note that if the changes aren't showing up it is probably because of caching so clear your browser's cache (F5 works on many browsers.)

Use CCK to make a unique front page

The Lullabots suggested this one: If you want a custom front page, one way to do it is to use the Content Creation Kit. Basically, you make a custom content type which you will use only for your front page.

  • Make a new content type called "home."
  • Define a field for each area of your front page: "tip of the day", "about the site", whatever. Probably all text fields.
  • Create a "node-home.tpl.php" file. Remember, when Drupal is showing CCK nodes, it automatically looks for a node--NAMEOFTYPE.tpl.php file. So you don't need to change template.php.
  • Format each field that you defined. If you created a field called "tip of day", you would do this...
<div id="custom_html_div">
<h2>Tip of the Day<h2>
<?php print $node->field_tip_of_day[0]['view']; ?>
</div>

You can get a list of what your fields are named by going to the "manage fields" tab under administer->content->content types.

  • Then create one node of this type and make it your front page. Like if it's node 34 you go to Administer->General Settings>Default Front Page and set that to "node/34" You could theoretically make other nodes of this type but the idea is that you're only going to need one node.
  • RoleAssign: delegate assignment of selected roles

    for similar functionality see Role Delegation

    RoleAssign specifically allows site administrators to further delegate the task of managing user's roles.

    RoleAssign introduces a new permission called assign roles. Users with this permission are able to assign selected roles to still other users. Only users with the administer access control permission may select which roles are available for assignment through this module.

    Pages

    Subscribe with RSS Subscribe to RSS - Drupal 6.x