2007-05-30

5 Steps to implement multisite in Drupal

There are already many use cases for multisite with one installation Drupal. The handbook of Drupal has some useful tips too. see: Multi-site installation and set-up

Here is just another typical one:

The customer needs two kinds of presentations of the same content, and such presentations should be decided by different URL.

More concretely, assumed that we have a domain named "http://www.example.com". This is the main site used for some people. At the same time, "http://www.example.com/show/" will be used for some other purpose, e.g. as a content provider with different front page.

Let's do it step by step:
  1. Find the configuration file httpd.conf of your Apache server. Add the following line at the end of the file.
    Alias /show "C:/Programme/xampp/htdocs/drupal/" #<- The path to your drupal directory. It can be "/var/www/htdocs/" on a linux server or alike.
    It maps the path to your drupal installation directory.

  2. Go to the /sites directory under the drupal installation directory. Copy the /default directory to a new directory with all the containing files. The new directory can be called "/www.example.com.show" or "/localhost.show". It depends on where you install your drupal.

  3. Make changes to the settings.php in the new directory.

    1. Since we use the same database and don't want to create new tables, we use:
      $db_url = 'mysql://name:password@localhost/drupal';
      $db_prefix = '';
    2. For the URL we use, change the base URL:
      $base_url = 'http://localhost/show'; // NO trailing slash!
    3. Something we want to change is the theme and front page, etc. It can be achieved by:
      $conf = array(
      'site_name' => 'My Drupal site',
      'theme_default' => 'pushbutton',
      'anonymous' => 'Visitor',
      );
  4. To get clean URL's with multi-site I added the following to the .htaccess file
    # rewrite commands for drupal dev sites
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^/show/.*
    RewriteRule ^(.*)$ /show/index.php?q=$1 [L,QSA]

  5. restart the Apache server and go to the URL "http://www.example.com/show/" to see what happens.
There are some bugs on using another theme with the different URL. For example, the blocks in the Drupal will be not shown correctly. The only solution currently is copying the main theme to a new directory with a new name like "showme".This makes a new theme with different name in Drupal, then edit it to fit your requirements.

Another "internal error occured during: Initializing Java tooling"

In 2007-05-02 I've already post a blog entry called "An internal error occured during: Initializing Java tooling", now this notorious error comes again!

Today I wanted to help someone to install the jBPM Graphical Design plug-in for Eclipse. I used the same version Eclipse and the plug-in as those on my own computer. Everything is fine until I tried to import a project from a CVS server. Then comes the error "An internal error occured during: Initializing Java tooling". It really makes me frustrated after I tried again and again and made 100% sure that all the software version are the same.

So where is the problem?

The bad guy is the setting in Eclipse! After going to "Window"->"Preferences...", you can see the following dialog:


Click the option "JBoss jBPM", you will see your installation directory of jBPM library and the name of installation. If you give a new name, exactly saying, a different name from the original name which you gave in your previous Eclipse. BOOM, you got the error!

The reason: Eclipse saves every project settings in a file called .classpath. It's a xml file. You can find a line like this:
<classpathentry kind="con" path="JBPM/JBoss jBPM 3.1.2"></classpathentry>

See? The name which is used here is the convenient name! So if you change this name, Eclipse doesn't know where to find the library again.

Solution:
1. Keep using the same convenient name in the preferences settings.
2. Change the entry in the .classpath file to the name you used.

2007-05-29

Node Template has been updated!

Before a three-days camp in Rotenburg I submitted a Drupal module "Node Template". After coming back from the camp, I've found there is already an issue existed for my module. Wow, it makes me really happy. At least it means there are people using that module.

The issue is about the version for Drupal 5.x. Since I didn't make any test on Drupal 5, I didn't even know it doesn't work for Drupal 5. All I have done is doing a conversion or update of my module from version for 4.7.x to version for 5.x according to a page called "Converting 4.7.x modules to 5.x", but without test it doesn't even work!

So after looking at the completely new API of Drupal 5, I fixed all the strange problems. Best of all, it helps me a lot because I'll develop another module called "Version table" in the very near future.

And here is also a screenshot of the module:

2007-05-23

Node template in Drupal

Drupal is one of my favorite CMS. For a recent project I need a plug-in that can duplicate a page or a branch of book nodes. Even more I want to set them as node templates, so that I can use them for further actions.

I've looked at so many modules of Drupal, but none of them meets my requirements. So...sadly I must do it myself. The result is, I wrote a module called "node template", which can be found at http://drupal.org/project/node_template.

It's my first module project for Drupal. So I hope I have more free time to make it better. Although setting up a CVS release of that module cost me already 30 minutes to figure it out, finally is it there. :)

2007-05-15

Best tutorials on Sending Email from Flash using PHP

I've tried a lot of tutorials on the web, in order to make a working contact form in flash. Endly I found one: Sending Email from Flash using PHP

The best part of that tutorial is: it points out tons of tips which could drive man crazy without. For example, you'd better hide the send button in a Movie Clip, so that everything works. Why? because otherweise

Note: note that [ send ] is a Movie Clip with inside a button. This is useful for us while with the loadVariables() our vars to PHP without sending all _root variables...
Reading such kind of tutorials is really an enjoy. Keep going on, Alessandro Crugnola!

2007-05-14

Using the UIScrollBar component of Flash

In a recent project I tried to use the UIScrollBar component of Flash 8. There are already a lot of tutorials on the web:
  1. Creating a Flash Textbox Input
  2. Creating a Text Scroller
If you do that step by step, it works. BUT, if you create a new text box with the type of dynamic text, use LoadVars to load a text file on the fly and add a UIScrollBar component to it, then publish it, you will see a blank vertical bar on the right of the text box. So what's wrong?

There are also people writing comments on the Adobe livedocs. Such things cost me at least one hour to find what happens.

The key to the solution is: you must enter something long enough in the text box before loading anything into it! I guess the UIScrollBar component just caculates the behavior before it's published. The only size it knows is your text size in the design phase.

So, don't forget to paste some dummy text in your text box and give it an instance name before you use the UIScrollBar component!

2007-05-13

JavaScript based google customized search

Today I found a JavaScript based google customized search from JavaScript Kit.

The idea is: using the format of a search string with "site:"+"yousite.com"+" "+"query value"

With the form you can use the following:
<form action="http://www.google.com/search" method="get" onSubmit="jssearch(this)">

2007-05-03

Sending Email in Flash

Contact form is used widely on a website. If the website is powered by Flash, find a better way to build a flexible contact form is also very important.

There are probably 3 ways:

1. Use the "mailto:" protocol

Namely set a button event with

on (release) {
getURL("mailto:" + to + "?subject=" +subject+ "&body=" + body);
}
The three variables are self defined in Flash according to the form fields.  A tutorial can be found here.

The advantage of this method is that man doesn't need complex programming things. The flash will call the email client in the system to send the mail.

The shortcoming is also related to the advantage: If an email client isn't setup well or doesn't exist on the system, then we have a problem.

2. Use FLASH and PHP

It's used widely. So I don't want to talk more abut it. ;-) 

The principle is: Flash posts Variables to a PHP file, then the PHP sends email using mail() function and returns the result to flash.



A tutorial can be found at kirupa.com

3. Load a HTML into FLASH

The principle here is trying to load a html with contact form in Flash.

Firstly just use a textfield in Flash, set it to dynamic. Then click Render Text as HTML in properties or set the .html property to true. Then use Loadvars to load the html file and assign the variable into the textfield.htmlText property. Here's an example:
loadText = new LoadVars();
loadText.onLoad = function()
{
_root.helpText_txt.html = true;
_root.helpText_txt.htmlText = this.testText;
}
loadText.load("text.htm");
Just remember the following: You don't need all that header junk like tags and such. At the beginning of your html file, above everything else put something like:

testText =

where testText can be any variable name you choose. You can only use jpg and swf's for graphics embedded in the html. And the jpg's can't be progressive jpg's.

Finally anchors "<a href="http://www2.blogger.com/bla.html">" will work but won't show as a different color unless you use font tags around them and specify to change the color of the text. ie. "<span></a><a href="http://www.blogger.com/bla.html">Bla</a></span>"

More infos about "Formatting text with Cascading Style Sheets" can be found here.

P.S. According to this article, there are many ways to link a html in Flash.

2007-05-02

To use Firefox or not to, it's a question

It's very interesting to find this on the web. Since I am a fan of firefox (maybe you too), I find the conclusions here are not so easy to believe. ;-)

So start to face the facts of firefox!

Firefox Myths

Another word, I've been starting using opera for a long time.

An internal error occured during: Initializing Java tooling

Since I updated my jBPM plugin for eclipse, I get the error "An internal error occured during: Initializing Java tooling" everytime when I start eclipse. Sometimes it becomes even worse, I cannot commit changes to CVS server or do something else in eclipse.

The reason is that the new version has changed the file structures and didn't provide the coresponding convension tools. So here is endly the solution:

  1. Backup the whole workspace before upgrading;
  2. You can enable or disable a new version jBPM plugin under "help"->"software updates"->"manage configurations";
  3. After the new version is running, create a blank process project, then create a blank process definition;
  4. Close eclipse, find the folder where the new created process files are;
  5. Open gpd.xml and processdefiniton.xml of the new process and your old process in an editor;
  6. Just compare the difference between those files. Mostly the new version of jBPM changes the structure of gpd.xml;
  7. So change the xml structure manually and save them;
  8. Maybe the file .classpath should alse be compared and changed.
  9. Open it in eclipse. If you are lucky, you will never see the error message again.
Hope it helps.