- "Ask the Expert" or Advice Column
- "Must Have" Modules
- A Challenge
- Books Overview
- Changing Garland - A Practical Example
- Comparison of Links and Web Links modules
- Create Simple Tables
- Creating a "Biographies" page
- Developing a Module on a Windows System
- Generic Table Display
- How to page a custom DB query
- List Users From a Single Role in a Block
- My Modules
- Announcements: Special Notices for Your Site
- Attendance Matrix
- Content Type Template
- FAQ_Ask
- Get Content Type
- Glossary
- Gotcha - Contact Spam Catcher
- Helpers
- Indexpage: summary of node type information
- Longer Node Titles
- Node Type Filter
- Quotes
- RealName: Using Profile fields to set a user's displayed name
- Register_Country
- Site Documentation Module
- Site Notes: Hidden Design or How To notes in Your Database
- Spam Tokens
- Spam Tune
- Taxonomy Browser
- Taxonomy Delegate
- Taxonomy Image: Associate Images with Taxonomy Terms
- Taxonomy List: Displaying Lists of Terms
- SBS Web Site Notes
- Searching for a New Hosting Company
- Taxonomy Tidbits
- Theming a Specific Content Type
Content Type Template
This is a generic content type moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP..
All pieces of the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. are here together and will need to be split after doing the initial customization.
- To start that you should create a new folder in the appropriate "sites/xxx/modules" directory.
- Copy the content_type_template.txt file into that folder; then work on the copy, which will become your moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP..
- Using a text editor (e.g. Wordpad), you need to "replace all" the following:
- replace $content_name$ with the human version of the content type.
- replace $content_type$ with the internal name (no spaces or capitals)
- replace $content_modifier$ with an extension (primarily for permissions)
(it may contain spaces and capital letters)
for example, the content_name may be "Site NotesA Drupal contributed module by Nancy Wichmann for hidden design or how-to notes." and content_type "sitenotes"
For example, for a newsletter type, you might use " article". If you don't want this, then replace it with nulls (""). Make sure if you do use this to include a leading space.
- Now split this template into the components that are identified with "start" and "end" comments.
- Go to another moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. and copy LICENSE.TXT if you want to distribute the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. you create. (Optional if it's only for personal use.)
- Check your customizations that might be needed. Then enable the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP..
Once that's done, you may discard the copied template (keep the original just in case).
This is now a pretty good starting point for you to do further customization. For some people this may be enough as it is. Either way, enjoy it.
README.htm
This will be customized in the above steps.
$content_name$ ModuleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.
The $content_name$ moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. allows the administrator to create a new content type (“$content_type$”).
The “$content_type$” type, as initially configured, is pretty much a clone of the “story” content type. There are three main reasons for using a custom content:
- So that taxonomies do not get confused with other content types.
- To allow for special rendering through CSSCascading Style Sheet - a hierarchical means of specifying how to format HTML elements on the page or themeFor web sites, this refers to the "look and feel" of the site. It is also used to describe the code to produce that look. templates.
- DatabaseA collection of data related to an application. queries can be limited to this type.
While the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. may be used without taxonomy (categories), it is really designed to be used with them. Multiple vocabularies (categories) are supported. For example, for a newsletter, one may define an “Issue Date” category and a “Keyword” category and both can be used to access the content. The Category moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. is not supported and no testing has been done with it.
After creating this moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. from the template, you are not only welcome to change it, but encouraged to do so. The real purpose of this template is to produce a working (and decently featured) starting point. Additional customization is available to do even more special things for your users.
Installation
This moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. installs a bit differently than the standard manner simply because of how it is created; follow the template instructions.
Following installation, you should go to the Content Type Settings page and set the default workflow options. I recommend turning all of those options off (including “published”).
Next, define the taxonomy vocabulary (-ies) that you want to use.
Start creating content.
See how it looks and adjust your CSSCascading Style Sheet - a hierarchical means of specifying how to format HTML elements on the page if you need to.
Installation Note
There is a bug in the core Node moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.. Check the issue status. It is a simple change and must be applied in order for this moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. (and others) to work correctly.
Administration
There are two administrative functions:
- “Configure permissions” allows you to determine which user roles can do what with the “$content_type$” content. The access permissions are defined as:
- Access $content_name$ -- alows the content to be viewed.
- Create $content_name$$content_modifier$ -- allows a user to create this type.
- Edit $content_name$$content_modifier$ -- allows a user to edit the type, whether it is theirs or not.
- Edit own $content_name$$content_modifier$ -- allows a user to edit only his/her own content.
- Change weight of $content_name$$content_modifier$ -- allows a user to change the weight of a posting so that it moves up or down the list independently from the creation date.
- Administer $content_name$ -- allows the user to control the administrator settings.
- “$content_name$ Settings” allows you to control how the content appears.
- Use content teaser -- specifies whether the normal display will use a teaser format.
- Number of columns in the index -- This sets the number of columns that can be displayed in the index page.
- “>> read more” linkThe technique which points to another page, anywhere on the Internet, from the current page. text -- This allows the user to change the text displayed for the links to the full text when teasers are used.
- "More from" author linkThe technique which points to another page, anywhere on the Internet, from the current page. text -- This allows the user to change the text displayed for the links to more contributions from the same author.
- $content_type$_description -- Your $content_name$ description. This will be placed at the top of the page, above the selected content and can serve as an introductory text.
- Categorize list -- This allows the user to display the content according to the categories configured on the add/edit $content_type$ page. The Taxonomy moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. must be enabled. The following options require this to be enabled.
- Display category name for index -- This allows the user to toggle the visibility of the category name above each index group.
- Display term list for node display -- This allows the user to toggle the visibility of the term list above each node (the "submitted by" line).
- Display term description for index -- This allows the user to toggle the visibility of the term description in the index.
- Display category name for content -- This allows the user to toggle the visibility of the category name above each selected node.
- Display unused category term -- This allows the user to specify if the terms index should include terms that are not used (count = 0).
- Display author names in index -- This allows the user to toggle the visibility of the author name list on the index page. Requires "Categorize list" to be selected, otherwise it will be defaulted on.
ModuleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. Invocation
/$content_type$
If the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. is entered with no arguments, then an index is displayed. This contains a list of all taxonomy vocabularies (categories) that are assigned to the "$content_type$" content type (if using categories) and a list of all $content_type$ authors.
/$content_type$/keyword/nnn
When the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. is entered with a single argument, it is the ID of terms to be used to select a list of nodes to display. This is the same format as can be used with “taxonomy/term.”
/$content_type$/author
If no argument is used with the “author” specification, then a list of the titles of the most recent submissions for each author is displayed.
/$content_type$/author/nnn
When entered with an author's user ID or name, all submissions from that author are displayed.
Blocks
Four blocks are defined in this moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP.:
- “$content_name$ Categories” -- id="$content_type$-block-0"
This block displays the taxonomy terms that are in defined as links.
- “Recent Pink Slips.” -- id="$content_type$-block-1"
The configuration includes a setting for how many post titles to show in the block.
- “$content_name$ Authors” -- id="$content_type$-block-2"
This block shows the list of all $content_name$ authors and a count of how many submissions they have made.
- “Unpublished $content_name$$content_modifier$s” -- id="$content_type$-block-3"
This block shows the list of all $content_name$$content_modifier$s that are waiting to be published.
Block Visibility Recommendations
The “Page specific visibility settings” for the first three blocks should be set to “Show if the following PHPRecursive acronym for "PHP: Hypertext Preprocessor" - is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. code returns TRUE” and include this code:
<?php
if (arg(0) == '$content_type$') { return TRUE; }
if (arg(0) == 'node') {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
return ($node->type == '$content_type$');
} /* end node */
?>For the “Unpublished $content_name$$content_modifier$s” I recommend setting it to show only for the roles that have the authority to approve the post, and limit it to the “Admin” page and all “$content_type$” pages (“$content_type$/*”).
Additional Blocks
Another block that might work well with the $content_name$; is the “Author Information” block that is provided with the Profile core moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP..
Set the visibility to something like this:
<?php
global $user;
$match = FALSE;
$types = array('$content_type$' => 1, 'faq' => 1, 'recipe' => 1); /* <-- change the types here */
$p0 = arg(0);
$p1 = arg(1);
$p2 = arg(2);
if ($p0 == 'node' && is_numeric($p1)) {
$nid = $p1;
$node = node_load(array('nid' => $nid));
$type = $node->type;
if (isset($types[$type])) { $match = TRUE; }
if ($node->uid == 1) { $match = FALSE; }
}
if ($p0 == '$content_type$' && $p1 == 'author' && $p2 != '') {$match = TRUE;}
return $match;
?>$content_type$.install
This moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. has an “install” component that also includes an “uninstall” function. The initially set install function only logs a message that the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. has been installed. The uninstall function does more:
- Removes all nodes with the “$content_type$” type. (Make sure you really want to do this.)
- Deletes the “$content_type$” content type.
- Deletes all system variables associated with this moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP..
- Clears the cache so that no remnants are displayed by accident.
- Logs a message indicating that it has been removed.
Following removal of the moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP., you may want to clean up any taxonomies that you had created for this content type.
Special Functions
There are some special functions that can be used on a custom page. These can be used in a handy-dandy overview index page.
- $content_type$_term_index -- creates a list of all the taxonomy terms associated with a vocabulary.
- $content_type$_author_index -- creates a list of all users who have created a $content_type$ node.
- $content_type$_author_count -- returns a count of how many $content_type$ nodes the author has created.
The first two functions will accept a parameter to specify the list type, which can be “list,” “table,” or “stream.” The list format produces an unordered (bulleted) list; the table type produces a table (with a heading); and the stream format separates the items by a bar (“|”).
The third function requires a parameter to specify which author to count. It may be either the user's id (numeric) or user's name.
The term_index function requires a numeric parameter to specify which vocabulary to traverse.
Examples:
- print $content_type$_term_index(8, "table");
- print $content_type$_author_index("list");
- print "Nancy has written " . $content_type$_author_count(47) . "$content_modifier$s.";
Additional Information
The weight feature is implemented in pretty much the same way the Weight moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. does -- that is it highjacks the “sticky” attribute. “Sticky” still works but it may look funny if you browse the actual databaseA collection of data related to an application. contents.
All the queries, except the Unpublished and Recent blocks, sort by weight (and “sticky”) in ascending order, then creation date in descending order, so the most recent posts are first. If this meets your needs, which it should for most people, then there is no need to worry. If not, you will have to locate all the queries and fix them. Generally, I would rather twiddle with the creation date in the “Authoring information” to make this work my way.
The Recent $content_name$ block does not use the weight/sticky field in its sort; it is purely by creation date.
The Unpublished block sorts by creation date in ascending order so that the posts that have been waiting the longest are on top.
-- This moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. was created from the Generic Content template (version 1.0) by Nancy WichmannThe beautiful, intelligent woman who runs this site..



Where is the download?
Hi Nancy,
Interesting stuff! But where is the download or dis I miss something?
Cheers, Joep
No, you didn't miss it
This is not a contributed moduleAn add-on, or extension, to Drupal to provide additional functionality; written in PHP. yet, so you have to email me for it.