Pager at top and bottom of comments

Originally posted as http://drupal.org/node/79352#comment-223909

This snippet places a pager at the top of the comments on a node, in addition to the default pager at the bottom.

Menu item title and description callbacks, localization

Titles underwent several noteworthy changes in the Drupal 6.x menu system rewrite. While these changes add some crucial new flexibility to the menu system, the majority of contributed modules are unlikely to need most of the new features. In accordance with this fact, this page is organized with the most commonly-useful information at the top, and becomes more complex as you go along.

Of all the changes to the menu system in D6, there is one that ALL module developers should be aware of:

Titles and Descriptions should no longer be wrapped in t().

As of 6.x, Drupal internally handles the translation of menu titles and descriptions into the user's local language. Descriptions, if provided, are always translated with t(); there is no way to pass in additional data for placeholder substitution (in D5 and prior, passing in substitutions was a discouraged practice - with this change, the menu system enforces that rule directly). Titles are translated with t() by default, but t()-style string replacement is possible through the use of the new 'title arguments' property. You can also choose to replace t() with your own custom callback.

SiteNotes: Adding Hidden Design or How To notes in Your Database

Ever design a site and happen on a nifty trick that you may want to use again? You wrote it down and lost the paper, didn't you.

You designed a great site for someone else, and the first thing they do is call you up and say "How do I do...?"

You can't remember all the modules, themes, and CSS changes you made and it's time to upgrade...

You'd love to put all that stuff on the web site, some place easy to find, but safe from casual hackers...

Display taxonomy terms broken out by vocabulary

Note: See comments for several alternative approaches, each w different priorities and different results.

By default, taxonomy terms are displayed in the node by the function print $terms

This results in one big array of all taxonomy terms associated with that node, no matter what vocabulary. Sometimes it makes sense to break these up, so that the terms are displayed by vocabulary. For example:

  • Topic: foo, bar
  • Tags: bat

To do this, use one of the following approaches:

Method A: (Drupal 6 ONLY)

The following breaks up taxonomy by vocabulary, or, if you pass it a vocabulary id (vid) it will print only that vocabulary which corresponds to the vid you passed to it. If you pass it a true or false value, it will also print or not print the terms as ordered lists. Useful for teasers.

Add this following snippet to your template.php file, minus the php tags that surround it:


<?php
function yourthemename_print_terms($node, $vid = NULL, $ordered_list = TRUE) {
$vocabularies = taxonomy_get_vocabularies();
if ($ordered_list) $output .= '

    '; //checks to see if you want an ordered list
    if ($vid) { //checks to see if you've passed a number with vid, prints just that vid

Example: Accessing a service from Groovy or Java

The Groovy language bundles XMLRPC service in the download. That, and the fact Groovy is a dynamic scripting language, makes it an interesting language to use for XMLRPC applications.

This example uses the echo service elsewhere in this handbook.

On the serverProxy line enter the correct URL.

Go into the Administration >> Services section and click on the Keys tab. Click on Create Key, enter anything for the Application Title and leave the Domain blank. Then paste the value you're given into the value for apiKey.

Then for userName and password enter appropriate values.

In the line saying serverProxy.echo.echo enter any message you want to have printed.

Run the script using the command line: groovy echo.groovy


import groovy.net.xmlrpc.*
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.Mac;
import java.nio.charset.Charset;
import java.nio.ByteBuffer;

def host = "localhost:1080";
def serverProxy = new XMLRPCServerProxy("http://" + host + "/cms/services/xmlrpc")
def csets = Charset.forName("US-ASCII");
def sharedkey = "";
def nonce = ""+System.currentTimeMillis();
def timestamp = System.currentTimeMillis();

Pages

Subscribe with RSS Subscribe to RSS - Drupal 6.x