webmonkeying
Drupal 7 notes - forms with file field reloading page without going through form validation
I had a problem shortly after setting up ownCloud and Piwik where forms on all of the Drupal sites on my server mysteriously stopped working.
But not all of them, only the ones with a file field. When hitting the submit button on those forms (and it didn’t matter what the form was, the presence of a file field was enough) the form validate wouldn’t trigger, the page would simply reload.
Webmonkey notes setting ssl piwik and owncloud under subdomains linode
As per usual part tutorial and mostly notes for me and anything with ridiculous names (e.g. username and domain) means replace with your information.
Ingredients
- 1 Linode
(this one has my referral attached because I’m a bastard like that)or equivalent - 1 copy of Piwik
- 1 copy of ownCloud Server (grab clients for your devices while you’re there if you like)
- 1-2 ssl certificates (depending on whether you can use wildcard certificates and are going to be running Piwik and ownCloud from the same domain, I like StartSSL but any certificate from anywhere will work)
I downloaded Piwik directly to the Linode (saves two steps of downloading it and then uploading it, plus my upload speed is crap) and ownCloud conveniently has many packages.
Have you tried turning it off and then on again?
This morning, when I crawled out of bed and tackled the morning coffee sites to be followed by 3d work before our busy day commenced, I noticed that my server was slow.
There goes my 3d time again, sigh. Now I would have quickly investigated, if it hadn’t taken FOR FREAKING EVER to log into the server, and I had to leave before it had logged in, and unsurprisingly the pipe had broken and annoyingly the problem hadn’t resolved itself when I was able to tackle it again later in the day.
Drupal 7 install profile stuff that everyone else magically knows
Seeing as I found little to nothing when searching for how to configure individual role permissions, editor settings and enabling contrib filters with an install profile, I made something on the off-chance it helps some other poor sap like me who doesn’t automagically know where to look for these things.
Enabling filters provided by contrib modules
Search in the .module
files for _filter_info
. Some modules use the same format as Drupal filters of $filters['modulename_filter']
, others don’t. Typogrify doesn’t:
Drupal 7 notes: node or page template by path
Because I always seem to manage to completely forget how to do something this basic.
template.php
in theme_preprocess_page(&$variables)
or theme_preprocess_node(&$variables)
<?php
$path = drupal_get_path_alias();
if (strpos($path, 'part_of_url') !== false) {
$variables['theme_hook_suggestion'] = 'page__whatever'; // or node__whatever if using in a node preprocess
}
?>
This work is marked with CC0 1.0 Universal
Drupal 7 upgrade from HELL
Modded to be slightly more useful as I wrote the other one while slightly delirious.
- upgrade to latest D6
drush arb default --destination="wherever/you/like"
- mysql
update
systemset
status='0' where
filenamelike 'sites%'
- delete 6.x, retain
/files and /sites directories
, remember any mods to.htaccess
- drop in 7.0 files
drush updb
- if no error, press
y
- if error occurs, make a note of what you need to do to fix it. If this is a repeat run, fix all errors noted
- rename/move your Drupal directory (or delete it but in the event you need it later)
- from above where the Drupal directory should be,
drush arr [backup-filename-without-square-brackets].tar
- repeat from 3 til everything works
drush up -y
- go do all the other little bits and pieces you need to do with the theme and modules
Problems I hit
- managed file duplicates:
mysql select * from `files` where `filepath` like `%string%'; delete from `files` where `fid`='number';
I only had a handful to deal with at any one time so didn’t mind doing them one by one, you’ll probably want a script if you have a lot :) - comment stupidity:
drop index comment_uid on comments; drop index last_comment_uid on node_comment_statistics;
This work by ryivhnn is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License
Drupal notes: backup process with drush
There’s probably a script for this. Or maybe drush is the script. Is all good, some things are done much faster with commandline :)
drush vset maintenance_mode 1
drush cc all
drush arb default --destination=../[site]-[date].tar
And if there’s updates to be done:
drush up -y
At the end:
drush vset maintenance_mode 0
This work is marked with CC0 1.0 Universal
Blog updates, or mile long sidebars
I can’t even count in miles.
I was a touch concerned about adding anything else to the sidebar as it’s already quite long. Then I had a look at the sidebars some of my friends and other miscellaneous people have on their blogs and I don’t feel too bad adding a couple of blocks. Then of course there was a mental kerfuffle about folds and whether blocks should be above or below them. I eventually decided to keep “About” up the top as it summarises the silly blog, and drop everything else in under it.
Sharing is...
…privacy concerning if you’re one of those people that object to things like tracking you around the internet, and not a big deal if you’re not.
It bugs me a little bit (especially as I realised recently that I’d forgotten to mention tracking cookies and scripts etc that would have been coming from the share module I was using in my privacy thing) so in the event it bugs anyone who happens to drop by I’ve replaced the module I was using for sharing with [Social Share Privacy](Social Share Privacy). Anywhere you see +1/Like/Pin/Tweet/etc buttons on a website, it’s set scripts and cookies and things in your browser already (unless you have a Fortified Firefox). What this module does is load the button image for the socnet in question but doesn’t set the cookie or the scripts etc. Your first click will activate the button so it can plant its cookies and scripts and do its little tracking thing. Your second click will launch the sharing thing.
Brain implosion imminent. Or what's been happening.
My head. It’s so full of stuff that I have a very mild persistant headache. The cold isn’t helping either, it makes my shoulder hurt. I’m glad I don’t live somewhere that’s actually cold.
Following is a thought dump so I can work out what I’m doing and so anyone that cares can now know why techno was gone for the last month and why I’ve been in such a ridiculous distracted foul mood.