Blog
How to Change a Field Type in Drupal 6? There are a lot of ways to do this. For non-programers such as myself, I find it easiest to let Drupal do the heavy lifting by just creating a new filed of the correct type and then copying the data over with a simple MySQL query.
Go to your content type and create a new field of the correct type. Then go to MYSQL and empty the new table (you don't need to do this if you're feeling cheeky and want to add an ON DUPLICATE KEY UPDATE to your query). For me, I just find it easier to empty (truncate) the brand new table and not have to worry about any mess that's already there because it won't be needed.
Then run a query something like this:
INSERT INTO content_field_NEW (vid,nid,delta,field_NEW_value) SELECT vid, nid, delta, field_OLD_value FROM content_field_OLD ;
Ahh, the magic of MySQL.
Go to the backend and get rid of the old field. If you want to then rename the new field to the old field, repeat process.
Of course, there are more sophisticated ways to do change a field name in Drupal running an ALTER TABLE ... CHANGE query and doing an UPDATE the content_node_field table but that's for another blog.
Also be aware that after updating the database in Drupal 6, you should always go to /admin/settings/performance and clear the cache. There's a little bug in Drupal 6 that causes the caches to be out of sync so what you see on an edit page my not be what's in the database unless you clear the cache.
more »One of the things I find most frustrating about Drupal is that it habitually generates tons of duplicate pages, URLs, and stubs that will absolutely sink you in the search engines. You optimize for one URL and, low and behold, Googlebot has picked up some other page that you didn't even know existed.
Modules such as Taxonomy, Views, and Quick Tabs among others are all habitual offenders producing loads of duplicate content and spammy URLs behind your back that can cause painful drops in your site's SERPs if left unchecked. One even needs to be wary of Drupal's core.
If you don't configure your robots.txt correctly - you can say adios to all your hard work getting the pages up in the SERPs. If you are a Webmaster as opposed to a Developer, knowing how to configure your robots.txt is essential business. Don't overlook it. It's not a non-essential. It's a TOTAL ESSENTIAL with many !!!!!!.
more »The moment you enable the core path.module (an essential core-optional module that's even better when used with the fantastic Pathatuo module) so you can control your ULRs, you've created duplicate content as far as Google, Yahoo, Bing et al. are concerned.
For example, you might see the page as being at http://www.greencrescent.com/blog/481/why-drupals-global-redirect-module-should-always-be-installed but if you're not careful, Google might see it as http://www.greencrescent.com/node/481.
What's worse, they will read the exact same content on two different URLs.
Ouch!!!
Praise the good folks that made Global Redirect.
If you care the least bit about organic search engine traffic (and you should) and want don't want your URLs to come out like /node/1234 (and you shouldn't) for many reasons beyond cosmetic issues and search engines (to be explained in other posts) then you should always and everywhere install Global Redirect. To see what it does, just click this link: http://www.greencrescent.com/node/481. See that? You come right back here. An not only do you come right back here, you do so in a way that tells Google that this /blog/481/why-drupals-global-redirect-module-should-always-be-installed and not this /node/481 is where they ought to be looking (in tech talk, by making the /node path a permanent 301 redirect).
That, as of this writing, Pathauto has 201,633 reported installs while Global Redirect has only 60,442 reported installs means that perhaps as many as 70% of the Drupal population may be screwing up.
(And possibly more because we don't know how many are using path.module without Pathauto.) Let's hope all those are test sites.
Global Redirect is important. Really, really important for Drupal...
more »I bet not as fast as you could. Here are a few tips to make setting up a Drupal website even faster (if you have command line access to your server).
- Go to http://drupal.org/project/drupal right click on the tar.gz version you want (as of this writing it's 6.20) and copy the link. It should look something like this:
- SSH to the folder housing the public folder on your server.
# cd /var/www/vhosts/yourdomain.com/
- Remove the public folder (in our case its called httpdocs) like this:
# rm -rf httpdocs
- Get the Drupal tarball:
# wget http://ftp.drupal.org/files/projects/drupal-6.20.tar.gz
- Untar the file file that's now in your public file.
# tar zxvf drupal-6.20.tar.gz
- Rename it so that it replaces your public folder:
#mv drupal-6.20 httpdocs
Beats the hell out of FTP.
more »Throughout the ages, man and pondered many things. Among them, how to bulk update data based on a content type in Drupal. At long last, we have an answer:
UPDATE yourColumn LEFT JOIN node ON node.nid = yourColumn.nid SET yourColumn = 'yourData' WHERE node.type = 'yourContentType'
Here you are doing a few things: You're telling MySQL to update the table you want to update. Then you're telling it to make sure that the NID (NODE ID - Drupal's unique node identifier) column you want to update is that same as the NID in the node table, the place where Drupal stores the content type information about the node, matches up ok. It then tells MySQL to put your data in there when the NID matches and the content type is the one you want.
May God bless you!
more »I find that during the course of building a Drupal site, oftentimes I find myself wishing that I had created more descriptive field names. As in, why was this field named field_blah when field_foo makes the purpose so, so much clearer. It's something of a cosmetic issue, to be sure, but also one that has to do with basic professionalism and organization - trying to make a site as clean and optimal as possible.
There are a variety of approaches to doing this. There is even a Drupal module: http://drupal.org/project/cck_field_rename ... which I tried out and it broke the database. Oh, well, that's why one should always make a backup before doing ANYTHING with one's data.
So, what do I think is the best way to do it? Well, just create a new CCK field with the name you want, move the data over with a MySQL query.
If the columns are in the same table (i.e. you're just changing the name and not the field type) it's as easy as:
UPDATE yourTable SET newColumnName = oldColumnName
If they aren't it would be more like this:
UPDATE newTable LEFT JOIN oldTable ON newTable.nid = oldTable.nid SET newTable.newTableColumn = oldTable.oldTableColumn
Voilà, painless... takes about 30 seconds including all the logins.
more »Google maps are one of Google's most popular features. I use them constantly as an individual who needs to find the location of something on a map and as a web developer who wants to help other people find the location of something by integrating Google Maps into our websites. On of the things that's not so easy about Gmaps is finding the coordinates of a location. However, the coordinates are there, you just have to dig a little bit to find them.
At the moment, I know of only one way to find them, there may be others but this is the only way I know... but hey, works perfectly.
The first order of business is going to http://maps.google.com/ and searching for something.

In my case, I was searching for the coordinates of The Cosmopolitan Hotel in Las Vegas which brings me to the second order of business...
Find the location, click the little red marker icon and see the little pop-up bubble to make sure that you've got the place selected.
The next step is to click on the Link icon near the upper right corner. It's currently next to the Edit, Print, and Send icons.

Double click on the bottom of the two fields that reads "Paste HTML to embed in website" and copy the code that's there.

Paste the code into a .txt file or something similar.
The code should look something like this:
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?client=safari&...- « first
- ‹ previous
- 1
- 2
- 3
