webmonkeying
Thoughts on DiSo
I’ve had several.
Simultaneously, I’ve had several thoughts on which way this post was going to go. Originally I was going to go along the vein of a blog post from Zauber Paracelsus (which outlines the “nymwars” debacle to the date of that post, people embarking on “Project DeGooglefy” and alternatives to Google services).
Then I was going to do something or other about G+ and Facebook and problems with centralised social networks.
Drupal 7 notes: unsetting formatting tips
Following on from hiding unwanted elements in comment forms, I found this tip on one of the many threads in Drupal of people trying to hide the pesky formatting guidelines and came up with:
template.php
<?php
function [theme_name]_form_comment_form_alter(&$form, &$form_state, $form_id)
{
$form['comment_body']['#after_build'][] = 'remove_tips';
}
function remove_tips(&$form)
{
unset($form['und'][0]['format']['guidelines']);
unset($form['und'][0]['format']['help']);
return $form;
}
?>
That gets rid of everything but the fieldset container and for the roles that can use multiple text formats, the select box (the “Text format” label can be easily removed with $form['und'][0]['format']['format']['#title'] = '';
in the comment_form_alter
).
You're doing it wrong
Here was supposed to be yet another whingepost about how I’m doing everything wrong and there is now nothing that I “can” drop. So I’m going to see if I can somehow write myself into doing “it” right.
The computer room is a f***ing mess
There is more crap than there should be on the desk. Most of it is paper that needs to be filed or recycled, and I have just been too damn lazy to process them into the appropriate location.
Drupal 7 notes: node--[type].tpl.php being ignored
If you change the machine name of a content type, make sure you bump all the nodes that were created under the old machine name. If that doesn’t work or there are too many of them, change them in the database.
In the below example I was trying to theme the “estimate” nodes with node–estimate.tpl.php. It wasn’t working because node 1 in this case still had the original type of “screen”.
Drupal 7 notes: the submit button on the node creation form isn't working!
In template.php
:
<?php
function [theme-name]_theme($existing, $type, $theme, $path)
{
return array
(
'[content-type]_node_form' = array(
'render element' =>
'form', 'template' => 'node--[content-type]-form', )
);
}
?>
If you keep template files in a subdirectory (eg sites//all/themes/[theme-name]/templates
or something to that effect) this may help:
'path' => drupal_get_path('theme', '[theme-name]') . '/subfolder',
After you’ve put all your fields where you want them in your pretty node--type.tpl.php
:
<?php
echo render($form['title']);
echo render($form['field_[field_name]']);
// etc
// with whatever formatting around it
?>
At the end put
Drupal 7 notes: unserialize() and undefined index notices after importing users from a csv
Long title is going to break my pretty layout.
So following on from the task of having to import a csv file of users into Drupal 6, I upgraded that install of Drupal 6 to 7, then exported the users, user roles and role tables into csv files for insertion into the database at work. Of course I had to test it out on my local to make sure nothing was too broken.
Drupal 6 notes: dealing with a users.csv file
Think I’m one of the few people on the planet who could have trouble with something as basic as this.
Problem: csv dump of the users table will not import no matter how you tweak the settings.
Solution:
- open csv file in NeoOffice (or whatever your spreadsheet thingi of choice is). I had to edit mine to change the user1 in the csv to uid 2 as there is already a user1 in the D7 it will be going into, other people may not need to edit theirs
- save the file, and keep it in csv format rather than changing to the native format of the spreadsheet
- using phpmyadmin, go to the database and find the users table, and select import
- browse for the csv file, leave all settings as they are, press go
In my case running the thing through NeoOffice stuck semi-colons all over the place which apparently made it easier for phpmyadmin (or MySQL, not sure which) to deal with. User table inserted.
Work, Wannabe and other projects and a dash of unschooling
[minor pseudonymising edits during Drupal to hugo migration for all the good that will do now]
Firstly, what in the hell is with the life category?!
I’ve been (very slowly!) importing livejournal entries so I can replace missing photos. Very minor regret that I didn’t bother skimming through my shadowshifter livejournal before I deleted it as I probably had a few progress reports for my various projects kicking around on it, but oh well.
Drupal 7 notes - putting submenus in different places from the parent menu while keeping your active-trail
By default, when you set up a child menu, it appears directly under and slightly indented from the parent item. Occasionally, there is a need (such as with the kiosk I’m currently working on for the Christmas Island Tourism Association) where you need an active-trail but the menus need to be in different regions.
Rather trying to do everything with blocks in regions I found it easier to dump code in templates.
Drupal 7 notes hiding unwanted form elements comment forms
Just so I don’t drive myself completely insane again.
It’s a fairly standard theming problem, you have your Drupal comment form rendering thusly:
Your site is set to not allow posting by anonymous users, rendering the “Your name” field superfluous and you think the subject line looks ugly, is unnecessary or you just don’t want users giving their comments subjects for whatever reason.