Monthly Archives: January 2010

How to remove the “Welcome to your new website…” message on front page

How to remove the “Welcome to your new website…” message on front page in drupal when no content is promoted to the front page. I wanted to do so because I have views on the front page, but nothing else, and I found that not having content promoted to front page makes drupal display this message. We have to modify the archive modules>node.module, in line 1751:

“$output = ‘ ‘;
$num_rows = false < == change this to “true”
…and the default message will be gone for good but again, everytime you upgrade your core you need to edit this portion. This was of help:

http://drupal.org/node/168457

Advertisements

Formating views promoted to front page

The best settings to output a view of recent events as a block promoted to the front page:

-style: html list.

-row style: fields.

-filters: node type= event.

-fields: node:Nid (excluded from display), node:title (ticking output this field as a link and using a link path of “node/[nid]”. These settings allow to output the title wrapped in a hyperlink to the node id, make sure that Node: Nid comes *before* Node: Title, as they are order dependent. (the order of the fields has to be properly arranged).

I chose to add a display of type block, and after saving it, from site building > blocks I configured the block to show on only the listed pages (<front>).

The following discussion was of help:

http://drupal.org/node/501692

Attaching images

To be able to attach images, the image module has to be installed and enabled. Then from content management > content types, all content types that need image attachments can be edited and under image attach settings attaching images can be enabled (it is disabled by default). Now when content is created there is a section called attached images, down below input format, and from there an existing image can be attached or a new one uploaded. Still, image positioning is an issue.

http://www.youtube.com/watch?v=2VKStNDj25k&feature=related

Views on content types

It is difficult at first to figure out how to create a “recipient” for content, so that all published content is wrapped under a menu item in the navigation bar that acts as the wrapper. Views is the module that allows to address it. I created a custom content type event, with added custom fields location and when, and wanted to view on this content type. This is done by filter on node: type, and then when page refreshes choosing “is one of: event” (under node type).  Row style has to be changed to node, and style to html list. Then clicking on add display of type page we can specify the path of the page, I used event. After saving the view, a menu item has to be created on primary links, with a path of event. Following link helped:

http://drupal.org/node/185741

users, roles

I created few random users, both from the administration menu and also putting the user to register a new account. Ran into the php mail() function error. Not a drupal related error but rather a web server one, as I´m using wamp locally, so had to modify the php.ini to include my isp´s mail server address. After some testing now it works. This was of help: http://email.about.com/od/emailprogrammingtips/qt/Configure_PHP_to_Use_a_Remote_SMTP_Server_for_Sending_Mail.htm

Users signing in become authenticated users, which as opposed to anonymous users, can now post comments and participate in the forums. Some users will be allowed to create content, such as blog entries, news, events etc., that´s why I created a new group called contributing user, and assigned roles to it from user management->roles: on top of ticking the same that an authenticated user has, I gave them also access to create page content and create story content (under node module), and create/edit/delete own blog entries, since this is a contributor who is going to be writing things.

I have also done my first steps with cck module, I have created a new content type called event and added custom extra fields like location.

Another error that took me a while to figure out was when I tried to create menu items and then content to fill them; intuitively, it looks easier to start with a site map and fill in the content later. But the best way is to create content and AFTER the menu item.

Forums in Drupal

To create forums in drupal the forum module has to be activated, then from content management>forums>add container a container is created to group related forums, which in turn hold the actual topics. I have created a container called general and have thrown in few forums such as “Announcements”, “New to the forum?”, etc. with their respective description. The problem that I´ve had is that no path is specified on creation of container, and couldn´t see a forums link on the site´s navigation´s primary links, until after some reading found out that http://localhost/drupal/forum takes the user to the forums page. I still needed a button to link the user there, so I tried to create a page to hold the forums and container with a ´forum´path, but it would overwrite the forums and display just that page. Finally realized that from site building>menus>primary links a new menu item could be added with the path forum to point to the forums. Found the following link useful: http://tips.webdesign10.com/how-to-make-a-drupal-forum

The challenges from here are:

a- allocating user roles and permissions to access/maintain the forum

b- skinning the forum.

SEO possible issues and GlobalRedirect module

I didn´t realise but content published under an alias with modules path and pathauto enabled is still accessible if typing in localhost/scouts/node/4 , creat ing duplicates and having two URLs for same content, something that search engines don´t like. The module GlobalRedirect fixes this to get content only visible at one URL (i.e. requests for node/4 are now forwarded to “alias-for-node-4”).

Also, having a separate completely differently looking administration section seemed like a good idea, mostly for when users log in to publish content; that´s why I installed the rootcandy module, which provides a very simple dashboard and a top bar icon based navigation menu. It allows as well to customize the menu according to users´roles, something that will be explored down the line when roles are decided. The credit link at the bottom of the page, was removed by commenting the following line from template.php, as explained in http://drupal.org/node/325933:

$vars[‘closure’] .= ‘<div>Theme created by <a href=”http://sotak.co.uk&#8221; rel=”external”>Marek Sotak</a></div>’;

Another module that I installed is fckeditor, for drupal to replace textareas with this WYSIWYG html editor, to give users familiar with word-like text processors a more powerful editing tool. It is happening to me that as I move along in trying to get a good understanding of drupal mechanisms I am becoming more aware of the functionality desired and seeking for existing modules and the gap they try to cover.

Finally, had a hard time adding a simple Home button in the primary links menu linking to the front page. Got it to work by adding a page called Home, leaving empty URL path settings and saving it, and then going to site building>menus>primary links and editing Home from there, to add in its path <front>. It wouldn´t work by adding it to the URL path settings on page creation.

Clean URLs

Trying to get rid of “q?=” generated in dynamic pages, found in sites configuration->clean URLs that the clean URLs option is disabled by default and couldn´t be enabled even though the .htaccess file was properly configured in the root folder. In the Apache web server configuration in my wamp server I enabled the rewrite_module, restarted all services and got drupal to allow me to activate clean URLs, therefore getting now http://localhost/scouts/node/1 instead of previous http://localhost/scouts/q?=node/1

With regards to the pathauto module, I have been trying it with not only newly generated content but also with previously generated one, and it works fine, adding /content/ in the URL, something that may or may not be desirable in some cases. This can be tweaked  in site building-> URL aliases>automated alias settings->node path settings, where patterns can be created for different content types. The default content/[title-raw] can be changed there.

More on modules

After playing with different themes to collect ideas before designing my own theme, for simplicity in the administration menu I installed the administration menu module to provide a theme independent interface. I didn’t quite like the small size of the font and it’s short separation though, so with the help of firebug identified the selector in the stylesheet and increased padding and font size.

I also downloaded and installed pathauto, to be able to create user and SEO friend aliases to the content. Normally drupal path would be http://www.example.com/node/4 (node id) but when you install this module, you can manipulate the drupal path with user friendly URLs like www.example.com/content/some-text.  The path module in the drupal core allows users to rename URLs, but the pathauto module, as the name implies, creates automatically path aliases for content without requiring the user to manually specify the path alias. The path module comes disabled by default, I enabled it and consequently enabled pathauto as well. Turns out that Pathauto module depends on the token module, which I downloaded and installed. Not too sure what it is for, but it is a requirement. The automated alias settings can be highly customizable, but for the moment it creates a URL based on the content title and using a “-“ as a separator, as I have seen many websites do (blogs, online papers and a long etcetera, often adding the date of the published content as well).

On a side note, I am reading Emma Jane Hogbin and Konstantin Kafer´s Front-End Drupal book, which hopefully will teach me how to convert my web page design into a drupal theme. Found first chapter´s explanations on content types very useful.