Drupal Theming

Print a form, such as a search form, anywhere in Drupal

Key words and phrases: 
form anywhere print form print search form drupal print the searchform
search_form_in_page.png
Description & Info: 

Resolved error:

Missing argument 1 for search_box(), called in /sites/example/www/includes/common.inc(1352) : eval()'d code on line 5 and defined in /sites/example/www/modules/search/search.module on line 1037.

This was from code added to a page's content by a client or possibly even the previous developer. We completely redid the site but did copy-paste in some pages.

Aquasoft / MGP-Forum style CSS background graphical menu for Drupal primary links

Key words and phrases: 
Aquasoft primary links CSS images php strip punctuation aquasoft css template.php punctuation function remove periods exclamation points
Description & Info: 

We first used this technique from the aquasoft theme on a 4.7 site, MGP-Forum, and just used it again, updated for Drupal 5 and with one enhancement by us.

Here's the D5 version from Aquasoft:

<?php
function aquasoft_primary_links() {
$links = menu_primary_links();
if ($links) {
foreach ($links as $link) {
$cssid = str_replace(' ', '_', strip_tags($link));

Show menu in page

Key words and phrases: 
display drupal menu within node print part of menu tree within content menu view inside
Description & Info: 

Set the input format for your node body or other textarea to PHP code, figure out what the menu ID of the menu item you care about as described by Nick Lewis (from whom all of this is stolen), and then stick this in your content:

<?php
$html
= theme_menu_tree(42);
print
$html;
?>

by Benjamin Melançon
Posted on Wed, 2008-05-21 13:10
in

Ask Agaric: Settings for a Drupal theme without requiring a module

Key words and phrases: 
theme config without bloat theming to provide user-configurable settings administration options for Drupal theme do not require module
Description & Info: 

Hi,

I've been breaking my brain over some issue and I cant figure it out so I
figured I'd check with a fellow themer(s?)!

[Related d.o. thread: http://drupal.org/node/247032 ]

What I'm basically trying to do is use drupal theme settings in a file
that is not processed by drupal, and its part of a theme. I also do not

by Benjamin Melançon
Posted on Thu, 2008-04-17 07:55
in

Drupal theming consulting- Panels and Views questions

Description & Info: 

Hi Benjamin,

Looking forward to talking tomorrow. I do have some questions ready so I'm inserting them below. I suspect we won't get everything covered in 30 minutes so if you do have time to extend to an hour that might be a good idea. I can pay ahead of time if you wish.

by Benjamin Melançon
Posted on Tue, 2008-04-15 10:40
in

Tools for working with color

Key words and phrases: 
color picker colour sets color wheel CSS HTML style design gradient complementary
by Benjamin Melançon
Posted on Mon, 2008-04-07 13:41
in

Theme admin_menu icon

Key words and phrases: 
drupal theme admin_menu
Description & Info: 

You don't really need to, because it's set to use the favicon if you've provided one in your theme settings.

But to override this, as described in the admin_menu README, simply copy this function (hidden in admin_menu.inc at the time of this writing) to your template.php file:

<?php

Printing classes for a theme depending on sidebar

Key words and phrases: 
phptemplate variables show body class layout
Description & Info: 

<?php
function _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'page':
// our own hook to remove sidebars from admin pages, not relevant here
if (arg(0) == 'admin') {
$vars['sidebar_right'] = '';
}

// layout for body classes
$vars['layout'] = '';

$layout = '';
//Is there a left sidebar?

by Benjamin Melançon
Posted on Mon, 2008-04-07 12:08
in

Theme Drupal search results

Key words and phrases: 
themeing search results view
Description & Info: 

theme_search_item($item, $type)

http://api.drupal.org/api/function/theme_search_item/5

http://drupal.org/node/175013 => Customize the search results page

A separate issue raised in IRC:

now to disable user searching.
[07:50am] ben-agaric: http://drupal.org/node/85137 - Remove tab from search page
Better general instructions for removing a tab: http://drupal.org/node/68792

In template.php, do not paste in opening <?php tag if one has already been opened and the closing ?> tag should be dropped from the end of all Drupal module and theme files per coding standards:
<?php
function phptemplate_search_item($item, $type) {
$output = '

'. check_plain($item['title']) .'

';
$info = array();
if ($item['type']) {
$info[] = check_plain($item['type']);
}
if (user_access('administer content')) {
if ($item['user']) {

Theming the File Attachments in Drupal 5.x

Key words and phrases: 
theming drupal attachment file mimetype icons
Description & Info: 

Alrighty then,

If you're reading this then you've probably been searching for a way to theme the default file attachment table in drupal and add cool icons according to the file's mime type, (ie. if it is an mp3 then a music icon will show, if a pdf then a pdf icon, etc)

This is a quick and easy method to help you get this done on your sites and make people think you are cool...

first off, grab the icon files you want to use and put them in a folder called 'icons' in your theme directory.
here is a breakdown how the files should be named, so that they display with the right filetype:

default.gif
image.gif
msword.gif
pdf.gif
rtf.gif
text.gif
vnd.ms-excel.gif
vnd.ms-powerpoint.gif
zip.gif

by Dan
Posted on Thu, 2008-03-27 16:28
in