How I created this site with Drupal (III)

Trackback and pingback modules


Most probably, we want to know who is referencing our contents (and to be polite, make others aware when we cite theirs). To do so, Drupal offers the modules, trackback module and the pingback one.

The modules are two different ways of doing the same. I first used trackback but I almost never got a real trackback, I spent most of the time removing spam messages. This and the fact that in the pingback module pingbacks appear as comments (so to moderate them you don’t need a specific interface) made me change TO the pingback MODULE.

Blocking certain users FROM accessing a specific page


I recently had TO CREATE a page ONLY accessible FOR: Registered Users AND users WITH an id matching one OF the VALUES IN a TABLE X (e.g. TO make sure that users have signed up FOR a specific service before letting them access it). Here IS how I did it.

For the FIRST part, there ARE several Drupal modules (e.g. this one ) that can be used FOR this purpose. However, since I just had TO block users FROM a small NUMBER OF pages I decided it was NOT worth TO install ANY additional MODULE so I wrote the CORRESPONDING PHP code myself. FOR the SECOND part, it IS necessary TO access the database USING the functions provided by the Drupal database interface .

Btw, I’m not claiming this is the best code you’ve ever seen! Hope AT least it gives you a hint OF how TO handle this issue

// Accessing the predefined GLOBAL variable $USER
global $USER; 

//Checking if the USER IS registered (i.e. has "authenticated user" AS a role)
if (in_array('authenticated user', $USER->roles)) 
{
  //If so, we CHECK a ROW FOR the USER EXISTS IN the TABLE X
  $result = db_query('SELECT x.id FROM mola_tableX x WHERE x.id=%s',$USER->uid);
  $EXISTS=db_fetch_object($result);
  if ($EXISTS) 
  {
     //Everything IS RIGHT. Go ON WITH the page loading
  }
  ELSE {  //Dealing WITH the error   }
}
else{  //Dealing WITH the error }

Adding a “Most popular content” SECTION


This IS really easy now IN Drupal, since a “popular content” VIEW IS already predefined AND can be easily configured TO show, FOR instante, ONLY the most popular blog entries OF the site.

Using this VIEW requires enabling the COUNT content views OPTION IN administer->report->access log settings.

Once the VIEW has been enabled a new “popular” block also becomes available TO show the results OF the VIEW. AS an example see the most popular block ON the RIGHT COLUMN OF this site.

 mostpopularblock />

Among many other thigs, you can configure the VIEW TO define the NUMBER OF items TO display IN the block, whether TO use a pager (TO display AT the bottom a SET OF page links 1,2,…5 TO access NOT so popular results) AND the “more link” that opens a new page WITH the popularity OF ALL nodes IN the site, ordered starting WITH the most popular ones. IN this page, I’ve found useful to show next to each node link, the number of visits of the link (and in this page, the use of pages is recommended, I’ve preferred NOT TO overcomplicate the RIGHT menu WITH the pager IN there).

 mostpopularblock />

Sending email notifications FROM Drupal after creating a new blog post


Instead OF subscribing TO the portal RSS feeds , SOME people prefer TO GET updates FROM this modeling portal directly TO their email. That’s why I created a news mailing list (subscribe to the list if you also prefer to get email notifications of the new blog posts and other updates from the portal)

Until now, I was writing and sending a summary of the new information posted in the portal every two weeks but I realized this is not a sustainable solution (it´s hard to remember and find the time to write that email and basically you are repeating information you already wrote before).

Therefore I decided to configure Drupal to send automatic notifications to the mailing list every time I write a new blog post

This way, all subscribers get an immediate update on the portal changes. There are probably more sophisticated ways to do this but a quick and easy fix is the following: use the Actions module to configure an email notification action that will be triggered (Trigger module) after the event Save a new post.

Sending an email is one of the predefined actions types in the Action module. You can create an email template that will be instantiated depending on the parameters of the event. For instance, see the action for my news list email notification (the %title and %node_url variables refer to the title and url of the new post; there are other variables available)

After this, it is just a matter of using the Triggers module to tell Drupal to execute the previous action every time the “save new blog post” event is executed

Other modules used in this site


A short description of other drupal modules used in this site:

  • Google analytics automatically adds the Javascript snipped required to track the visitors in google analytics.
  • Contact form activates a predefined contact form in the site
  • Mollon adds an image and audio captcha to avoid spammers in the user registration form
  • Custom error permits to create custom error pages for 404 (not found), and 403 (access denied) errors.
  • Language icons replaces the language name with the language flag in multi-lingual sites.
  • AddThis module: to facilitate the sharing of the portal contents

Check also the first and second part of this series


Lunarpages.com Web Hosting

2 Responses to How I created this site with Drupal (III)

  1. [...] a wordpress site IS much easier than a drupal one (remember that the Modeling Languages portal IS USING Drupal so I’m USING BOTH AT the same TIME). Nevertheless, one thing that I dislike FROM wordpress [...]

  2. facebook123 says:

    Websites you should visit…

    [...]below you’ll find the link to some sites that we think you should visit[...]……

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by WordPress