Drupal

Blog subject related to Drupal

Display lengthy legalese/explanation static text in CCK

in

Often there is a need to make some big block of text in the middle of a CCK input form. And on node display, show that same text and the value of the text field. Something like this:

An important requirement is your site admin (often your non-technical client) can edit the text. Any sort of CCK form widget require permission and change to the form. Not easy for plain user.

But CCK fields just don't have any way to include lengthy text. They can have help text which are displayed below the input in gray text. The second problem is I need this text to be shown when the page is displayed but the various modules I found (markup, form_markup) do not show anything on output. So I created the nodeincck module to solve this need.

Wysiwyg filter guide

in

Drupal core comes with two input formats: Filtered HTML and Full HTML. Filtered HTML format lets both authenticated and anonymous users enter comments and contents safely by limiting the allowed HTML tags to a very limited set with the HTML Filter. Full HTML is indented for admin use only because it allows any HTML tags and attributes to be used. WYSIWYG editors make use of many more tags and attributes to satisfy the full range of format options. Since the HTML Filter is only capable of allow or dis-allow of HTML tags, it is inadequate for complete safety because Wysiwyg editors make use of a large range of HTML tags and attributes. But for safty from XSS and other attacks, HTML tags and and attributes must be very precisely controlled so the Wysiwyg editor can safely render full range of styling format. The Wysiwyg Filter precisely satisfy this need: it lets you specify exactly what tags and what attributes are allowed in such a way that gives you the full rang of HTML tags and attributes required by the Wysiwyg editors and yet keeping the format completely safe. It's a replacement of the built-in HTML Filter.

Minimaxpager Drupal module

in

This module turns Drupal's pager into a text box where you can enter the page to go directly to. It's very useful if you have many many page and need to go to any page very quickly.

Accountmenu Drupal module

in

This module provides a set of pre-made menu links for 'Login', 'Register', 'My account' and 'Logout'. After the user is logged in, he/she is returned to the page from where he/she clicked the login link. The 'My account' link is integrated with the realname module to use the user's actual realname. The 'register' link can be shown to take the user directly to the register page.

Provide pattern and suggestion theme templates from a module

in

Pattern and suggestion theme templates normally can only reside in the theme directory. This can make the theme folder filled with many many templates that can sprawl over time. This makes sharing templates between active themes impossible, switching theme or upgrading theme very hard. It would be much better to house these templates inside a module or inside some site/files folder. This makes module fully able to provide override theme templates out of the box. No copying files to theme necessary.

Theming CCK content type output display and input edit form

in

The Content Construction Kit (CCK) lets you define custom content type with many different kinds of data fields. The default display and input form are generic looking and may not be the way you like. But the look of the node output and the node edit form are completely customizable. I will illustrate how to do this by making change to the active theme. But at the end, I will show how to do this from a module, which is a better approach because it's not married to the active theme. This is better for site maintenance and allows you to freely switch theme.

Dynamic login/logout account menu module

in
Here is a Drupal module to provide a dynamic [Login][My account][Log out] menu. Before the user is logged in, the menu shows only [Log in]. After, the menu change to [My account][Log out]. This is an alternative to the "User login" block. Maybe you do not want the "User login" block on every page, taking up valuable space and grabbing user attention away from your contents.

Customizing site off-line/maintenance page

in
May you never come face to face with this:

Site off-line screen

This is the page Drupal will throw up if something is wrong with the database. The root cause of the problem is displayed at the bottom of the screen if "display_errors = On' is set in php.ini. But it's suggested in php.ini that this should be "Off" for production site. So you may not see what the cause of the problem is. There are a few things not so good with this page:
  1. The site name got changed to "Drupal", not your name.
  2. The site logo and favicon are the Drupal versions.
  3. Finally, the site is in the minnelli look
The good news is this page is fully customizable and I'll show the ins-and-outs about this here.

Block configuration form validation

in
It's not obvious from reading the api doc at http://api.drupal.org/api/function/hook_block/6 and http://api.drupal.org/api/function/block_example_block/6 how to do form validation for block configure form. The key is to realize they are form sub-elements that are part of a form defined by the block core module.

Drupal syntaxhighlighter module

in

(Update: this module has been updated to D7.)

This Drupal module does program code list syntax highlighting like this:

class Person(ln : String, fn : String, s : Person)
{
    def lastName = ln;
    def firstName = fn;
    def spouse = s;
    
    def this(ln : String, fn : String) = { this(ln, fn, null); }

    def introduction() : String = 
        return "Hi, my name is " + firstName + " " + lastName +
            (if (spouse != null) " and this is my spouse, " + spouse.firstName + " " + spouse.lastName + "." 
             else ".");
}

It uses the Syntax Highlighter Javascript library to perform the highlighting on the client browser.

訂閱文章

Navigation

使用者登入