Create block id attributes based on block title

Description

Change block #id tags using the "Block title" field. This provides easy and portable styling, "id=address" instead of "id=block-block-24".

Step 1 of 2

Set up a variable using a preprocess function and ensure that it is correctly formatted for #id attributes.

template.php

<?php
/**
* Override or insert PHPTemplate variables into BLOCK templates.
*
* @param $vars
* A sequential array of variables to pass to the theme template.
* @param $hook
* The name of the theme function being called ("block" in this case.)
*/
function mytheme_preprocess_block(&$vars, $hook) { //change mytheme to your theme name
$block = $vars['block'];

// Create css id attribute based on 'Block title' when available.
if (!empty($block->title)) {
// Create the variable and ensure that it is correctly formatted with mytheme_id_safe function
$cssid = mytheme_id_safe($block->title);
}
else {
// If no "Block title", create css id attribute the traditional way.
$cssid = "block-$block->module-$block->delta";
}
$vars['block_cssid'] = $cssid;
}
/**
* Converts a string to a suitable html ID attribute.
*
* - Preceeds initial numeric with 'n' character.
* - Replaces space and underscore with dash.

Changing the delimiter on primary/secondary links

Note: See http://drupal.org/node/112761 for working with Drupal 5's primary links.

Drupal 6.9

Thanks to dman for a nudge in the right direction via his forum comment.

Copy and paste the theme_links function from theme.inc to your template.php file. change the name of the function to YOURTHEME_links where YOURTHEME is the name of your theme.

Add the following code snippet on the second line of the function, after the "$output=' ';"

<?php
// | delimiter added here.
	if($attributes['class'] == 'links secondary-links') {
    $linklist = array();
    foreach ((array)$links as $key => $link) {
        $linklist[] = l($link['title'], $link['href'], $link);
    }
    // Return the links joined by a '|' character
    return join(' | ', $linklist);
?>
  }

As it is currently setup the secondary links will have the delimiter.

Next go to your page.tpl.php file and insert the following code into where you want the links to show up.

<?php 
if(isset($secondary_links)){
        print YOURTHEME_links($secondary_links, array('class' => 'links secondary-links'));
   }
?>

Drupal 4.7

Locate:
print theme('links', $primary_links)

Comment mover: thread management for forums

The comment mover module allows you to move comments in a thread, move a comment to another thread and move comments to a new thread and vice versa. It can be used should a user post a comment in a wrong topic or posts a comment that should be a new topic.

Comment mover is designed to be integrated into the OG2List mailing list manager, but also works on its own for any Drupal site which has forums and comments. Redirectors to the new positions of the comment or node will be added as appropriate.

Log in while site is off-line for maintenance

Once you have turned your site off-line using admin » settings » site maintenance (admin/settings), you can log back in by visiting:

http://example.com/?q=user

Make sure to note: Use the literal word user, not your username or user id. Do, however, replace example.com with the proper URL parts pointing to your website.

Setup of /sites directory for multi-site

Drupal's multi-site hosting capability is built in with any installation. This is great news for users who run numerous web sites from a single hosting account. A single Drupal installation can be used to run multiple domains, which makes it much easier to manage and maintain the code base. Even if you are dealing with only one domain, the multi-site capability may be valuable by providing the ability to run a separate domain or sub-domain for a development version.

This page describes the set-up of the /sites directory for multi-sites.

Simple Decision Tree for Drupal Enterprise Scalability

Here's a scaling tree. As you progress up the tree, you will find that time, money, maintenance, headaches will all increase.

This guide assumes that you have multiple fast and beefy Web and DB servers.

  1. Enable MySQL Query Cache
  2. Use a PHP cache
  3. I found that using APC speeds up Drupal by a lot, 3 to 5 times the pages view per second. This was _literally_ a 5 minute install (on FreeBSD) for a 300% to 500% performance improvement. I think at that point it was my dev servers SATA HDDs were the bottle neck. It sits beside me and when I hit it with ab, I can hear the HDDs wrrrrr like crazy.

  4. Use mod_gzip (or ob_compress or whatever it is in php, I prefer mod_gzip, or mod_deflate in Apache2)
  5. The benefits of this are amazing, considering the minimal effort it takes to implement. If doesn't matter if it takes Drupal 0.002 seconds to generate a 40K of html, if it takes like 1 to 2 seconds for a client to download it (more if using a modem). mod_gzip usually gives a 10% to 80% compression depending on the size of pages. Amazing results for 10 minutes of work.

    To enable this feature, put the following code in your .htaccess file, if you are running with Apache 2 and mod_deflate enabled

    # Enable file compression by MIME type

Pages

Subscribe with RSS Subscribe to RSS - Drupal 6.x