Add this blog to Del.icio.us, Digg or Furl | Create Watchlist for this blog

Archive for the ‘CMS’ Category

CSS Selectors - Short Reference

Monday, June 23rd, 2008

This is a “short as possible” reference for CSS selector syntax. Intended audience should be very familiar with XHTML, DOM and CSS Styling.

Basics

Type selector
Select all HTML elements of a special type.
Example: em {font-weight: bold;}
Class selector
Select all elements with a given class.
Example: .classname {font-weight: normal;}
ID selector
Select the one element with a given id.
Example: #idname {font-weight: normal;}
Concatenator
Select HTML elements of special type only with given class/id.
Example: em.classname, em#idname {font-weight: normal;}
Universal selector
Select all elements.
Example: * {padding:0;}
Descendent selector
Select all elements that are lower down in the DOM tree (descendants).
Example: p em {font-weight: normal;}
-> Applies to all em's within p's.

Advanced

Child selector
Select all elements that are children in the DOM tree (direct descendant).
Example: p > em {font-weight: normal;}
-> Applies to all em's directly within p's, not supported by ie6 and below.

Adjacent sibling selectors
Select all elements that are on the same DOM level in the same DOM subtree
Example: h3 + p {font-size:80%;}
-> Applies to all p's that "belong" to a h3

(more…)

Installing Drupal 6 “upgrade save”

Friday, April 11th, 2008

Drupal is upgrading very frequently. Specially nowadays as V6 is out for a view weeks. If you don’t want to get mad upgrading Drupal every other day - here are some hints to follow when installing Drupal6.

Most important: If you have more sites running on one server: Do a multisite installation!

Assuming you have your Apache root at /srv/htdocs do the following:

  1. Download Drupal 6.1 and tar xvzf it in /srv
  2. Now you have /srv/drupal-6.1
  3. Create a symlink like ln -s drupal-6.1 drupal
  4. Now you also have /srv/drupal (pointing to /srv/drupal-6.1)
  5. Now create a symlink for apache: I.e. ln -s /srv/drupal /srv/htdocs/drupalweb and let your virtual domain (or where ever Drupal will run) point to /srv/htdocs/drupalweb as httdocs root.

Your ready with your update-prepared ionstallation.

When an upgrade to Drupal 6.2 appears (it did view days ago), do the following:

  • mysqldump your drupal database (just for security and possible rollbacks)
  • copy cp -r -p /srv/drupal-6.1 /srv/drupal-6.2 the 6.1 to the new 6.2 installation (so you can rollback if necessary)
  • in /srv/drupal-6.2 preserve your sites directory by renaming it, i.e. mv sites sites_old
  • now, in /srv untar the 6.2 distribution tar xvzf drupal-6.2.tar.gz
  • remove the new sites dir and move back your preserved: rm -r sites, mv sites_old sites
  • now relink your master: rm /srv/drupal; ln -s drupal-6.2 drupal
  • and browse to update.php of your site.

Keep in mind to check, if there’s something important new in settings.php…
And with this kind of installation you are perfectly prepared for multisite! And for sure it doesn’t work with MS scrappy OS’s.

And have fun!

Feeding “static” sites from Drupal nodes

Tuesday, February 26th, 2008

This is about how I manage to create content for domains without CMS from a Drupal enabled domain without any manual work.

On address www.immobilien-spot.de I am running a community for real estate agents. It’s primary focused on Immobilien in München (that’s German for real estate in Munich).

Estate agents can become members, can show 10 of their best buildings and act like usual in communities (Blog, Forum, Contact…). Additionally the agents can book a special site to promote one of their offers, i.e. an office loft for rent. This office loft is shown in the offer list and also on a static site called officeloft.de (this is an example, I don’t own that domain). To feed the content of officeloft.de from the Drupal content on immobilien-spot.de, I’ve established a special node type called a “promotion”.

A promotion node consists of a node-ref (pointing to the estate offer node), an entry place (office-loft.de) and a booking period (March 2008). To render the promotion node completely different from all other nodes, I have installed the sections and pathauto modules for Drupal. With pathauto one can automatically create special paths for nodetypes, and with sections.module one can assign special page.tpl.php for this path.

What’s left is to have a nightly cronjob that copies the rendered promotion node to the special site’s http-root directory (what should be a subdirectory of the main domains http-root - else you have to struggle with your OS). And finally transpose all of the relative path’s inside the copy to be absolute.

Have fun!

Drupal: Using node and user information in block code

Monday, January 7th, 2008

This is for Drupal 5, don’t know if it works also in version 6.

Usually block content is not related to the currently displayed node. I.e. the block that displays the recent blog posts always displays the same content, regardless of on what page you are currently looking.
I often had situations where I wanted the block content to be related to the currently viewed node. To keep the example: When viewing a blog post, I wanted a block to display the most recent post of the author of the currently displayed post, and additionally print some profile fields like age and a gravatar.

The key to achieve this goal is the Drupal arg() function. This function returns the components of the currently viewed path before any URL aliasing. So if you view the node 5, that is yourdomain.com/node/5 (and sometimes a trailing “view”), you will get following results from function arg():

arg(0) -> "node"
arg(1) -> "5"
arg(2) -> "" or "view"

Now, if you want to get some information about node 5, you use node_load(). And to get information about the user that is the author of node 5, you use user_load().

In PHP code it works out like:

if (arg(0) == 'node'
    && is_numeric(arg(1))
    && (arg(2) == '' || arg(2) == 'view')) {
 $node = node_load(arg(1));
 if (is_numeric($node->uid))
   $user = user_load(array('uid' => "$node->uid"));
 ... do something with $node and $user here
}

BTW: If you need this a lot, you should consider writing a module for your content type :-)

To make a useful example out of it…
I use the following “debug-block” while developing to view my node and user objects:

if (arg(0) == 'node' && is_numeric(arg(1))
    && (arg(2) == '' || arg(2) == 'view')) {
 $node = node_load(arg(1));
 if (is_numeric($node->uid))
   $user = user_load(array('uid' => "$node->uid"));
 print "node object<br>";
 foreach ($node as $k => $v) {
  print "[$k] = $v<br>";
 }
 print "<br>user object<br>";
 if ($user) foreach ($user as $k => $v) {
  print "[$k] = $v<br>";
 }
} else {
print 'not a node';
}

Started Beta of new Wii Community based on Drupal 5.3

Wednesday, December 5th, 2007

Yesterday I stared the beta run (this is very 2.0 webish) of my wiiclub project. It’s a community for Wii Gamers in German. It makes extensive use of lots of Drupals community features, like i.e.

  • the userpoints api
  • the fivestar rating
  • the buddylist module
  • the chartroom module
  • lots of image galleries
  • features cck types like a “game report”
  • uses forum, blog, poll

The site is very much web2.0 like, that means it has

  • community features
  • bright colors
  • orange button with gradient
  • gradients in backgrounds
  • big primary navigation
  • a star like beta-batch
  • rounded corners
  • centered non-table layout
  • cute icons
  • clear breadcumb

So, if you are addicted to Wii - come join us :-)

bildschirmfoto-wii-club.png

New Drupal company site on air

Tuesday, November 13th, 2007

Website der proxiss GmbH MünchenLast weeks I was working on a new Drupal driven company site. This time I wanted to create my theme from scratch (calles “ANewCompany”) and wanted to use heavy taxonomy for cross linking.
The site is on air now and promises professional web2.0 programming (German).

On the site I use following modules:

Blog, Book, Forum, Poll - for content creation
Comment, Contact - for visitor interaction
Drupal - for site registry
Locale - for string translation and adjustment
Menu, Path - for site navigation
Taxonomy - for cross linking and navigation
Search - for site wide full text search
Statistics - for access statistics
Akismet - for spam protection
Comment mail - for admin notifications
Service links - for social network linking
TinyMCE - as wysiwyg editor
Views - for some data mining and block representation
Fivestar, Voting API - for content voting

I developed a new page.tpl.php template where I’ve foreseen the regions as follows

  function ANewCompany_regions() {
      return array(
	  'header' => t ('header'),
          'content_top' => t('content top'),
          'content' => t('content'),
          'sidebar_left' => t('sidebar left'),
          'sidebar_right' => t('sidebar right'),
          'content_bottom' => t('content bottom'),
          'footer' => t('footer'),
          'super_footer' => t('super footer')
      );
  }


For the sidebars I use a table-less floating CSS layer concept for reasons i.e. stated here.
In my template.php file I overwrite theme_links for primary_links (to achieve rounded tabs as primary navigation) and the book navigation theme_book_navigation($node) to make it more nice. Special theming for blog and book content is done by node-blog.tpl.php and node-book.tpl.php files.

Next days I will working on a generalization of the theme to contribute it to the drupal theme repository.

Offering professional Drupal service

Saturday, October 6th, 2007

Rainer Feike Drupal ServicesAfter some months work with the fabulous Drupal system I have decided to offer professional services for that CMS in Germany. Based on Drupal 5.x I have created four websites last months, one for a community in the real estate business, one for stock investors and two drupal company sites.

I am really good in techniques like hooks, callbacks, templates and modularization from my business experience of the last years with C, C++, JAVA, PHP … on Unix and Windows. So it was pretty easy to get deep into Drupal (also thanks to my experiences with Wordpress and b2evolution as CMS’s). Drupal is fantastic.

Certainly, I will contribute my results (as far as allowed by my customers) back to the Drupal community as open source - and, if requested, I am willing to donate time and work to a German or international Drupal project. And to support the Drupal association with money, I will donate 5% of each Drupal related turnover (must check this against German tax laws first, probably I will have to use that 5% for advertising on drupal.org).

Drupal 6 entered beta stage

Wednesday, September 26th, 2007

– just a note –

Will write about it next days.

Drupal localization and string adjustment

Monday, September 17th, 2007

Sometimes when setting up a drupal site, the situation appears, that I need a “special translation” for a standard module. I.e. I need a blogging functionality - but I don’t want to call the system a “blog”.
That’s when I need a customized translation of the blogging module. This article is about how to customize drupal strings with the localization feature.

Find the strings to translate

What you need first the the GNU gettext package (it’s contained in every linux distro). From this package you need the program “xgettext”. This program is able to extract the strings from the module code that can be translated (if the module is programed very well, this should be all strings in the code).
Now go the the module’s location (usualy /modules/blog) and type:

xgettext.exe --keyword=t -L PHP blog.module

The L tells xgettext, that this code is PHP code, the keyword tells xgettext, that function “t()” is used for gettext translations. The output of xgettext is by default a file called messages.po. This file contains all translateable strings of blog.module.

...
#: blog.module:137
msgid "Post new blog entry."
msgstr ""

#: blog.module:140
msgid "You are not allowed to post a new blog entry."
msgstr ""

#: blog.module:178
msgid "RSS - blogs"
msgstr ""

#: blog.module:222 blog.module:257
msgid "Blogs"
msgstr ""

#: blog.module:239
msgid "@username's blog"
msgstr ""

#: blog.module:261
msgid "My blog"
msgstr ""

#: blog.module:277 blog.module:286
msgid "Recent blog posts"
msgstr ""

#: blog.module:285
msgid "more"
msgstr ""

#: blog.module:285
msgid "Read the latest blog entries."
msgstr ""
...

Translate the strings

Keep each string in messages.po that you want to translate, delete the one’s you don’t want to translate, rename the file to i.e. myBlogStrings.po. Now put your translation of each string into the “msgstr” field.
I.e.

#: blog.module:222 blog.module:257
msgid "Blogs"
msgstr "Articles"

#: blog.module:239
msgid "@username's blog"
msgstr "@username's articles"

#: blog.module:261
msgid "My blog"
msgstr "My articles"

Then save the file myBlogStrings.po.

Activate the drupal localization module

Go to Administer / Site building / Modules and activate the “Locale” menu.

Import your “translation” of the blog.module

Go to Administer / Site configuration / Localization and choose “importing a translation”.
Use the file selector to choose your “myBlogStrings.po” file, choose to import to your current language (most times it’s english (en)). And check “Strings in the uploaded file replace existing ones, new ones are added”. Then import the strings with button “import”.

You’re done, your blog is now a article collection.

Things to watch out

The character-set of your file must be correct (i.e. UTF-8). That means, you need an editor that’s capable of saving files in UTF-8 (I use PSPad) and don’t forget to change the CHARSET in line “Content-Type: text/plain; charset=CHARSET\n” of the xgettext program’s output.

Started New Drupal Project

Wednesday, August 29th, 2007

I’ve started a new Drupal project in the DAX Investment business. It’s kind of “pre-alpha” but it’s already a very interesting project from a technology view. It will contain blocks with high dynamical image content as well as stock quotes. So I will need to look somewhat deeper to caching technology and AJAX.
It will also contain community features like blogs and a forum, so there’s also lot of work to do with taxonomy.
I’ll keep you informed.