Author Archive for jefke

Eclipse or Aptana en Pydev: “Project interpreter not specified”

After installing pydev in aptana (trying out for Django-development), I got this error message: “project interpreter not specified”. Apparently this is an error that mainly hits non-English speaking people, as I found no solution in English. Google translate helped me out, but I thought I’d save you the trouble:
Go to: Window>Preferences>pydev>interpreter-python where you can set the python interpreter. For me, the “auto-config” button worked just fine…

Setting command prompt start directory for administrator in windows (7)

I bought a new computer, pretty cheap, pretty good. So I’m pretty happy with it. Its one weak point is that its 3D graphics card (which I do need) has no decent driver support under linux yet. So a good reason to leave windows 7 on it for a while, and find out how it works. I do miss linux, but I have no major complaints so far.
Something I brought over from linux, is wanting to use the command line, and I really needed it for playing around with Django. I guess the command line in windows is not really the same as in linux, and it doesn’t work as smoothly, but there is one. What I do hate, however, is typing in directory paths using the – for my finger less conveniently placed – “\”. So I wanted to start the command prompt in my Django directory. If you create a shortcut to the command prompt, you can set a directory where it has to start. If you run it as administrator, however, it still starts up in the system folder. Windows wouldn’t be Windows however, if there wasn’t a registry setting for this:
(start the registry editor with regedit in the start menu)
add to HKEY_CURRENT_USER\Software\Microsoft\Command Processor a new string value “Autorun” (if it’s not there yet) and set its value to “CD /d ” (E.g. CD /d C:\Users\User\Desktop)
And that works when you open cmd as administrator too…
(BEWARE, messing with windows registry can cripple your windows installation, so be careful and backup)

Drupal 6: adding and modifying html using javascript

A while ago, I had a simple website, with a simple js script for calculating a price based on some user input. The script uses an updater function that, after all required choices have been made (radio buttons), calculates the final price and shows the price. It does this by adding html to a predefined ‘price div’ (price.innerHTML = “…”) and setting it’s height from 0 to ‘auto’. Nothing fancy, but worked quite nice.
Upon changing the website for a Drupal site, I was confronted with implementing the js within Drupal. And even though it wasn’t really hard, it took me a while to figure it out, so I thought I’d share my findings, hoping they would be useful to somebody.

First of all, I created a normal page within Drupal. The downside of the method (to some people) is that I had to enable PHP for the page input. But as I am the only person ever seeing an input form on this particular site, I didn’t care too much. For adding the required js (and some extra css for that page), I used:

drupal_add_js(’sites/all/js/prices.js’); drupal_add_js(’sites/all/js/updater.js’);
drupal_set_html_head(‘<script type=”text/javascript”>
window.onload = function() {
includePrices();
};
');
drupal_add_css(path_to_theme().'/prices.css', 'theme', 'all', TRUE);
$styles = drupal_get_css();

And then I added an html form which calls the updater function on each click. This makes it possible to have the second choice customers have to make depend on the first choice they make.

<div onclick="update();" id="priceform">
<div onclick="update();" id="house_type">
<form id="typeform">
Type house:
<input type="radio" value="1" ...
</form>
...

Works like a charm for me...