Date and Calendar in Drupal 7

I have to wonder how many of those early release books written for Drupal 7 will end up becoming trash. I’m sure they will contain useful information but things are still changing. I discovered a good video titled Date + Calendar from the Drupal Therapy guys and decided to work through their example. It goes through the steps of installing the Date and Calendar modules then creating a new Event Content Type.

The problems started when I got to the steps they lay out for configuring the Date’s Views. It was helpful while frustrating because the Views settings page has changed so much. I finally got through the Views configuration without error messages and got the Calendar to display the correct date. As suggested, I replaced the downloaded Views, Calendar, and Date with the most recent Dev versions.

In the Administration->Structure->Views page for Calendar (Content) the page layout has changed substantially from the Feb 11, 2011 date the video was originally produced (not too surprising). There is not a Defaults selection or Arguments selection on the configuration page anymore.

I made three changes:

  • Replaced the values in CONTEXTUAL FILTERS with – “Date: Date (node) (Content: Date (field_date))
  • Under FIELDS set values to – “Content: Date (Date)
  • Under FILTER CRITERIA set values to – “Content: Published (Yes)” and “Content: Type (= Event)

My problem now is after the Event is published the Date and Body only show up when I select the web site’s home page. If I click on the Event article to view or edit, the published Date and Body disappear. Is anyone else having that trouble or know of a solution? (I do have Organic Groups installed in this site too if that matters).

 About SomeoneKnows 
(c) 2011 Vince Thompson

Advertisements

A Closer Look at Drupal 7

I use Google to find many of the things I want to learn about. Sometimes the list of links it returns can be a little disappointing. Upgrading from Drupal 6 to Drupal 7 is one of those situations that is bringing a variety of results that don’t quite hit the mark. Of course what I’m finding today will change in the days and weeks to come so your experiences will vary. I hope to continue updating this article as I find more useful information.

Sometimes the most obvious places get overlooked. For instance, the Upgrade.txt file in the Drupal7 installation is a good place to start looking. Here are some other good places I’ve started looking:

From the Drupal Handbook Documents Administration Guide look at these sections:
After you get a fundamental Drupal 7 installation working the following guides are helpful:

Database API

I haven’t found a nice pushbutton solution to upgrading the databases between D6 and D7. Diving into relevant database documentation is the best choice as I can see it right now.

Links Found That May Be Useful? 

I haven’t read the following articles yet but they may have some useful information so I’m bookmarking them here for now:

Database Migration

 About SomeoneKnows 
(c) 2011 Vince Thompson

Drupal 7 – Are We There Yet?

When I started picking up on Drupal I began learning about Drupal 6 because Drupal 7 was off in the distant future. Well, Drupal 7 was released for production on Jan. 5 this year and I’ve still been in the “sometime in the future mode” until the last few days (peeling back the onion some more) http://drupal.org/drupal-7.0. Now, work has begun on Drupal 8 to be released sometime in the future.

Drupal 7 has some features that make sense for a new web site I’m working on – Organic Groups and Web Services. While these aren’t new they have some updates to the way they work. The CCK and Views have been two of the most important modules for Drupal 6 web sites. It appears that Drupal 7 now replaces them with Fields. Drupal 8 is planned to include some features I want to design for like incorporating a higher degree of web services. I ordered another book that should arrive today, this one about Drupal 6 Web Services.  http://www.amazon.com/gp/product/1849510989 I see web services as an important component in connecting interactions between Drupal and MicroStation, AutoCad or other future CAD/CAE systems. Since I’m starting off with a new web project is seems like the best time to jump into Drupal 7 development.

Using Git to Download Drupal 7

I don’t understand enough about Git yet but was able to use it and get a copy from the Drupal Git repository. I was worried about making mistakes in setting up my local repository like where it should reside how can I undo a mistake. I made a few mistakes along the way and learned they could be erased by deleting the “.git” folder. If it turns out I overlooked something about erasing a repository I’ll add more information here. This article seemed to be helpful: http://drupal.org/node/803746#setup I managed to get a local site working with Drupal 7 last night.

I got a rudimentary install with Organic Groups and several other features set up within a Drupal 7 environment. So far, so good. Something I could use some help with is finding out what the recommended practice are to take the MySql database from its Drupal 6 configuration to Drupal 7. My initial search didn’t come up with a worthwhile suggestion yet. Maybe I’m just not looking in the right place.

 About SomeoneKnows 
(c) 2011 Vince Thompson

Drupal Taxonomy

Drupal has an unbelievable collection of features. So much of the time I feel like I’m constantly peeling away different layers of an onion trying to get to an understanding of what it does and how to make it work. It is designed to separate the programming code from the information. The information – things like labels, values for check boxes, radio buttons, or selection lists gets stored in the database while modules provide the programming framework. Drupal is a true database driven system

Taxonomy reinforces this separation of programming features from the information (data) and what it means. If  you’re spending some time learning about Drupal I thought you might find the following video interesting to watch. http://gotdrupal.com/videos/drupal-taxonomy It is a bit long around 50 minutes but it does make some good points about taxonomy and how its used.

Setting Up an IDE for Drupal Development

I founded a group in Kansas City called Make:KC in July 2009 inspired by Make Magazine, their Maker Faires, and the www.makezine.com web site. I started with a MakeKC WordPress blog using WordPress’ free blogging site. Then I registered our www.MakeKC.org domain name and started using Drupal in December 2009. Make:KC is a non-profit organization.

I’ve tried setting up an Integrated Development Environment (IDE) using Eclipse and then NetBeans. Both seem to work well as editors but I was having trouble getting a debugger working that would allow me to step through the PHP commands on our web site. Most of the time these tools have not been needed while using Drupal’s menu style configuration. But I’m wanting to work on developing some modules too.

NetBeans and xdebug

I tried to get debugging working for Drupal sometime last year. At that time I tried Eclipse and NetBeans. I’m spending more time learning to develop in Drupal so I need this to work. It helps to step through commands with a debugger and learn what takes place in Drupal’s code; learning why, how, and when commands are executed.

I’m sure Eclipse is a great IDE to work with but I managed to get debugging working in NetBeans first. I had an older version already on my computer but installed the newer NetBeans 7.0 version today and now I have debugging working on the server side.

I had already downloaded the xdebug program but setting it up to work with the IDE was my problem. I found this web site with some answers I needed: http://2bits.com/articles/setting-up-xdebug-dbgp-for-php-on-debian-ubuntu.html
The section about adding the following instructions to my /etc/php5/apache2/php.ini file seemed to make things work:

zend_extension=/usr/lib/php5/20051025/xdebug.so

[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

; General
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_params=off
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_local_vars=0
xdebug.show_mem_delta=0
xdebug.max_nesting_level=100
;xdebug.idekey=

; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp
xdebug.trace_options=0
xdebug.trace_output_name=crc32

; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=crc32

I need to read the article “Introducing xdebug”, it looks like it has some really good information: http://devzone.zend.com/article/2803-Introducing-xdebug

 About SomeoneKnows 
(c) 2011 Vince Thompson

Our Drupal Site Backed Up to a Laptop

Putting MakeKC.org on a Laptop

I have been spending time lately learning more about Drupal. The more I learn, the more I’m impressed with the system so I decided to write this up and post it to my blog.

I’ve wanted to have a local copy of our MakeKC live website on my home machine for testing and backup but I was having trouble getting the database installed. The phpMySql program wouldn’t let the large database dmp file load. The solution was actually simple but requires a command line keyin in the form:

mysql -u username -p databasename < backupfilename.sql

or in my case:

mysql -u makekcAcct -p databaseForMakekc < myHostingAcct-databaseForMakekc-4-25-2011.dmp 

I copied all of the files from makekc.org’s drupal6 directory down to my local machine. I have Ubuntu with Apache, PHP, and MySql installed. I copied the directory to my computer at:  ~home/www/makekc.local/drupal6 (where ~home is the shortcut notation for my home directory).

I added the a static IP address to the /etc/hosts file

127.0.0.1    localhost
127.0.0.7    makekc.local

(I happen to be using other ip addresses and the next in line was 127.0.0.7 at the time).

A Revelation About Website Root Directories

I’m using the versions of Apache, PHP, and MySql offered by Ubuntu’s Synaptic Package Manager. This causes my web site files to be placed off the root directory at /var/www/myVirtualDomains. Up until now I thought each of my local web sites had to go into the /var/www/ directory for special web site purposes. I wondered if pointing to a different web root directory inside my home directory would work. So I added the following to my /etc/apache2/sites-enabled/000-default file:

<VirtualHost makekc.local:80>
   ServerAdmin webmaster@makekc.local
   DocumentRoot /home/someoneknows/www/makekc.local/drupal6
   ServerName makekc.local
   ServerAlias www.makekc.local
   ErrorLog /var/log/apache2/makekc.local-error_log
   CustomLog /var/log/apache2/makekc.local-access_log common
</VirtualHost> 

Turns out it that pointing to a web root directory in my login account works there too.

With the website files and the web server configuration in place I restarted the server. Then navigated to the web page using makekc.local. The same homepage from the live website was showing up on my makekc.local site too. But when I tried logging in or going to one of the links in the site they didn’t work.

Enabling Clean URLs

I finally realized that the links to other pages probably weren’t working because Clean URLs are enabled on the live site but my default apache installation didn’t allow my Drupal install to Enable Clean URLs.  I didn’t take the time to learn how to apply the proper configuration at the time for my laptop computer to allow mod_rewrite to work.

It took a while but I finally found the command “sudo a2enmod rewrite“, this sets up apache to allow rewrites to happen. Then I changed the /ect/apache2/sites-enabled/000-default file again to change AllowOveride  None to AllowOverride All as in:

   <Directory />
       Options FollowSymLinks
       AllowOverride All
   </Directory>

After restarting Apache again I finally have a working local copy on my computer with the same contents and functionality as our live site.

 About SomeoneKnows 
(c) 2011 Vince Thompson

Preserving Formatted Source Code in HTML

I’m switching some of my WordPress blog content over to other web sites and reorganizing them into logical book type formats. One nice thing about the WordPress blog is the plugin that helps to format my C source code for Arduino programs and Processing.

I’ve tried copying and pasting the Arduino code into an OpenOffice document but the source code’s color formatting gets lost. I haven’t found a way of using the Arduino and Processing environments to save the source code with the formatting intact.

I started looking into ways of capturing the displays and saving them in Rich Text Format (RTF) documents then possibly writing a program to create the proper HTML formatting. Luckily I didn’t have to go that far. I have three different Integrated Development Environments (IDE) loaded on my computer in addition to the Arduino and Processing language IDEs. Since switching to Ubuntu from Windows a couple of months ago I’m experimenting with several new programming tools at the same time.

I loaded up some sample source code into the Code::Blocks IDE. Formatting based on the source code language shows up in the display. I tried the Save As feature but didn’t see alternate document formats listed. Then I noticed the Export feature. Under the menu item File->Export setting there are four options including HTML, RDF, ODT, and PDF. My goal was to produce the souce code in an HTML document anyway so I chose that option and it worked nicely.

After that I tried Eclipse. I didn’t find an export option and the Save As just used the standard dialog function to save the file with a different name. Eclipse is a great editor to work with and I hope to find a way to make this work.

The third IDE I’m getting to know is NetBeans. NetBeans didn’t offer an Export function but it does provide a File->Print to HTML feature that works nicely too. I found a plugin for NetBeans on the Processing web site. I am going to try the NetBeans Processing Template plugin to see how it works.

There seems to be some good articles about using Processing with Eclipse. I hope I can find an already developed function to create HTML from the formatted display. Also, I’m hoping the NetBeans plugin helps by including more formatting and keyword recognition to more closely match the Processing IDE display.

Anyway, I seem to have found an off the shelf way of adding line numbers to the source code display. The color coded formatting is being preserved and white space is not being smashed when converting into the HTML format.

About SomeoneKnows
(c) 2010 Vince Thompson