just a personal cut & paste page

martedì, luglio 26, 2005

tags life



web software design blog programming tools reference blogs news art css music howto fun linux webdesign javascript cool humor search funny internet development free google java mac games photography flash tutorial tech opensource rss webdev technology books ajax politics security business video media science tips windows osx html toread daily shopping firefox maps culture audio photo php hacks xml geek apple diy graphics freeware productivity photos history mp3 hardware ruby images computer code tool writing tutorials travel game book article wiki community python social gtd language hack blogging research del.icio.us movies links download inspiration rails network education podcast map articles resources flickr humour interesting tv food lifehacks usability computers podcasting learning microsoft library mozilla useful comics london mobile dhtml marketing tags database health networking film radio entertainment hacking photoshop email delicious wordpress xhtml animation shop googlemaps tagging unix reviews online philosophy api weird japan management utilities standards ipod extensions browser work dev visualization electronics extension uk life p2p cms people architecture literature gadgets gaming dvd magazine information collaboration gallery guide .net typography religion privacy accessibility folksonomy forum resource terrorism bookmarks mysql money economics perl sex hosting bittorrent sysadmin home plugin wireless socialsoftware math china movie jobs fonts psychology wishlist j2ee web2.0 greasemonkey downloads macosx journalism ui reading ebooks todo nyc misc personal world organization weblog ideas sql gps future recipes documentation mapping creativity geo framework interface retro pictures image japanese career phone directory service physics backup rubyonrails 3d apps palm read portfolio read_later portal fashion voip aggregator seo illustration activism advice layout xmlhttprequest stock dom debian patterns statistics desktop porn it webcomics server feed color coding finance school english usa dictionary torrents copyright gmail info syndication 2read anime services make environment streaming digital comic review testing crafts friends camera blogger editor law rest startup generator list feeds macintosh storage pda television dotnet wifi cooking wikipedia forums c++ ai yahoo icons pc artists space furniture
(red tags are tags you share with everyone else)

DRUPAL: PHP page snippets

PHP page snippets: putting dynamic content into your main page

Once Drupal is installed you will notice an option under CREATE CONTENT to create a PAGE. It is a standard out-of-the-box drupal feature and when creating a PAGE you have 3 filter options when submitting i.e. Filtered HTML, Full HTML or PHP.

The PHP Snippets below are intended for use within a drupal page filtered as PHP that simply enables you to "pull" specific content from your drupal database. Allowing you to create dynamic and sophisticated page layouts such those found at busy portals, such as www.mtv.com or www.yahoo.com.

Make sure you check the custom block examples as well.

  • Very simple to use and implement. Copy n paste snippets into your page
  • Allows users to insert "block style" content in the main page
  • build simple or sophisticated main page layouts with dynamic content
  • pull specific content from your drupal database to insert into a page

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

How to insert and use the PHP Snippets in your pages

The PHP SNIPPETS come with a brief introduction on what it does and if it only works with specific versions of Drupal.

Some are very similar to how you SETUP CUSTOM BLOCKS WITH CONTENT THAT APPEAR IN THE SIDEBARS but the snippets below are intended for use within your main NODE page as opposed to your sidebars.

Once you get used to how the PHP Snippets work and if you are familiar with how to setup up a HTML table or using DIVs, you can mix snippets together in the same page creating sophisticated layouts like those found at http://www.mtv.com or http://www.yahoo.com.

  1. Go to CREATE CONTENT -->> PAGE
  2. Give your page a TITLE
  3. In the BODY text area, paste in your PHP Snippet. Make sure you include the opening and closing PHP statements and remove any extra spaces, line breaks after the final ?> which tells drupal that this is the end of the php page.
  4. Select the PHP CODE filter.
  5. Click SUBMIT or PREVIEW to view your page.

More sophisticated layout/styling of node pages

The following is intended for people not familiar with PHP coding and illustrates how to apply styling to content inserted into a page using PHP.

Here is an example of a very simple PHP snippet that displays the Site slogan.

<?php
/**
* the following displays the site slogan
*
*/
print variable_get("site_slogan", "");
?>

Click for a simple example of how to add styling to the content displayed by the php snippet .

Using some simple HTML functions, such as creating a table or using DIVS, you can start creating much more sophisticated layouts using multiple snippets in the same page. For some guidance and tips it is worth looking at a more sophisticated php Snippet that inserts the site mission and a list of upcoming events in a 2 column table side by side, followed by a list of the recent weblog entries.

!--------------!---------------!
!--------------!---------------!
!------site----!--upcoming-----!
!----mission---!---events------!
!--------------!---------------!
!--------------!---------------!
!--------------!---------------!
!----recent weblog entries-----!
!--------------!---------------!
!--------------!---------------!

How to use the PHP Snippets with the front_page.module

USING PHP SNIPPETS WITH THE FRONT_PAGE.MODULE

Probably the most common use of php snippets will be the front page of your site.

To use any of these snippets using the front_page.module (allows you to specify a "splash" page to your site and different front pages for anonymous/authenticated users) Simply follow these steps once you have the front_page.module installed properly:

Step 1: Go to ADMINISTER -->> SETTINGS -->> FRONT_PAGE

Step 2: In the teaxt areas available, paste in your PHP Snippet(s).

Step 3: Select the ALLOW EMBEDDED PHP option.

Step 4: Select if you want a FULL/THEMED Front Page.

Step 5: Click on SAVE CONFIGURATION once you are happy with your front_page settings.

A guide to submitting your own PHP snippets

Please post your own snippets up here for others and follow these simple guidelines.

  1. Click on ADD CHILD PAGE from the main page in this section (PHP PAGE SNIPPETS: PUTTING DYNAMIC CONTENT INTO YOUR MAIN PAGE ).
  2. Give your snippet a short and obvious title so it is easy for others to see what your snippet does.
  3. Please include a simple introduction at the top of your PHP Snippet which explains:
    • What the snippet does
    • Which versions of Drupal has it been tested with
    • Any extra information for newbies that you think is relevant

Countdown (x) days to a specific date and display a dynamic message

PLEASE NOTE! The following snippet is user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* This php snippet displays (x) days left to a specific event
*
*
* Change the values for keyMonth, keyDay and keyYear to suit
*
*
* Tested and works with drupal 4.6 and 4.5
*/
$keyMonth = 7;
$keyDay = 14;
$keyYear = 2005 ;
$month = date(F);
$mon = date(n);
$day = date(j);
$year = date(Y);
$hours_left = (mktime (0,0,0,$keyMonth ,$keyDay,$keyYear) - time ())/3600;
$daysLeft = ceil( $hours_left/24);
$z = (string)$daysLeft ;
if (
$z > 1) {
print
"There are <font size=\"4\" color=\"red\">" ;
print
$z;
print
"</font> days left until whatever happens</p>" ;
}
?>

Create a list of node titles of a specific type, within certain dates/times

<?php
/**
* Creates a list of node titles of a specific type, within certain dates
* with a link to each node.
*
* To change which type is listed, simply edit the $node_type string.
* To change the starting date, simply change the $start_stamp.
* To change the ending date, simply change the $end_stamp.
*
* This works with drupal 4.6
*/
$node_type = "image";
$start_stamp = 'June 9 2005';
$end_stamp  = 'June 10 2005' ;
$start_stamp = strtotime($start_stamp);
$end_stamp = strtotime($end_stamp);
$sql = "SELECT node.title, node.nid FROM node WHERE node.created < $end_stamp AND node.created > $start_stamp AND node.type = '$node_type'" ;
$output .= "<ul>";
$result = db_query($sql);
while (
$anode = db_fetch_object($result)) {
$output .= "<li>".l($anode-> title, "node/$anode->nid")."</li>";
}
$output .= "</ul>";
return
$output ;
?>

display (x) random thumbnails in a page

PLEASE NOTE! The following snippet is user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* This php snippet displays (x) random thumbnails with a link to
* the full images in a page.
*
* (assumes you already have the IMAGE.MODULE installed)
*
* To increase/decrease the number of thumbnails listed
* change the $thumbs field to suit.
*
* Tested and works with drupal 4.6
*/
$thumbs = 0;
while (
$thumbs< 10) {
$images = (image_get_random($count = 1, $tid = 0));
print
l(image_display($images[ 0], 'thumbnail'),'node/'.$images [0]->nid, array(), null, null, FALSE, TRUE);
$thumbs ++;
}
?>

Display a list of (x) most recent weblog entries

PLEASE NOTE: The php snippets are user submitted and it is impossible to check every one, so use at your own risk. For users who have setup drupal using an alternate database to the default, please note that the snippets may contain some database queries that may or may not work.

<?php
/**
* the following displays a list of the 10 most recent weblog titles
* and links to the full weblogs. If you want to increase/reduce
* the number of titles displayed..simply change $listlength value
*
* This php snippet works with drupal 4.6.
*
*/
$listlength= "10";
$output = node_title_list(db_query_range (db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, $listlength));
print
$output;
?>

Display a list of (x) node titles of a specific type

<?php
/**
* Creates a list of node titles of a specific type
* with a link to each node.
*
* To change which type is listed, simply edit the $node_type string.
* To change the number of node titles listed, simply edit the $list_no number.
*
* This works with drupal 4.5 and drupal 4.6
*/
$node_type = "flexinode-1";
$list_no =5;
$sql = "SELECT node.title, node.type, node.nid FROM node WHERE node.type = '$node_type' LIMIT $list_no";
$output .= "<ul>";
$result = db_query($sql);
while (
$anode = db_fetch_object ($result)) {
$output .= "<li>" .l($anode->title , "node/$anode->nid")."</li>";
}
$output .= "</ul>";
return
$output;
?>

Display a list of (x) upcoming events in a scrolling box without javascript

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* The following snippet displays the next 10 upcoming events
* in a scrolling box that is set in a simple DIV styled inline.
* To increase or decrease the number of events listed just change
* the $listlength value
*
* no javascript is required and the current
* height, width is 150 X 320 pixels.
* to increase decrease that simply change the values for
* the $boxheight and $boxwidth
*
* works with most popular browsers
* Tested in IE6, Mozilla Firefox 1.0 & 1.5, and NN7
*
* Tested and works with with drupal 4.5.x and Drupal 4.6.x
*
*
*/
$listlength="15";
$boxheight= "150px";
$boxwidth="320px";
print
"<h1>Upcoming Events</h1><div style=\"unicode-bidi:bidi-override; direction:rtl; display:block; width:$boxwidth; height:$boxheight; overflow:auto; padding-left:10px; border:1px solid #ba8; \"><div dir=\"ltr\"><p>" ;
print  
event_block_upcoming($limit=$listlength );
print
"</p></div></div>";
?>

Display a list of a certain content type, with teasers

<?php
/**
* This php snippet displays content of a specified type, with teasers
*
* To change the type of content listed, change the $content_type.
*
* Works with drupal 4.6
*/
  
$content_type = 'story';
  
$result1 = pager_query(db_rewrite_sql("SELECT n.nid , n.created FROM {node} n WHERE n.type = '$content_type' AND n.status = 1 ORDER BY n.created ASC"));
  while (
$node = db_fetch_object($result1)) {
    
$output .= node_view(node_load(array('nid' => $node ->nid)), 1);
  }
print
$output ;
?>

Display a list of category titles with links to the full term

Please note: These snippets are user submitted. Use at your own risk. For users who have setup Drupal using a database other than the default (MySQL), please note that the snippets may contain some database queries specific to MySQL.

<?php
/**
* Creates a list of category titles with a link to each category term.
* And the number of items in each term in brackets. (x)
*
* Category term title (x) and link to full term
* date of last update
*
*
* This works with drupal 4.6 and 4.5.
*
* If you improve this snippet please post a new comment below.
*
*/
$result = db_query("SELECT d.tid, d.name, MAX(n.created ) AS updated, COUNT(*) AS count FROM {term_data} d INNER JOIN {term_node} USING (tid) INNER JOIN {node} n USING (nid) WHERE n.status = 1 GROUP BY d.tid, d.name ORDER BY updated DESC, d.name");
  
$items = array();
  while (
$category = db_fetch_object($result)) {
    
$items[] = l ($category->name .' (' . $category->count .')', 'taxonomy/term/'. $category->tid) .'<br />' . t('%time ago', array('%time' => format_interval(time() - $category-> updated)));
  }
print
theme('item_list', $items);
?>

Display a list of node titles from a specific category

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* Creates a list of node titles from a specific category
* with a link to each node.
*
* To change which taxonomy is listed, simply edit the $taxd_id number.
* To change the number of node titles listed, simply edit the $list_no number.
*
* This works with drupal 4.5 and drupal 4.6
*/
$taxo_id = 1;
$list_no =5;
$sql = "SELECT node.title, node.nid FROM node INNER JOIN term_node ON node.nid = term_node.nid WHERE term_node.tid = $taxo_id LIMIT $list_no";
$output .= "<ul>";
$result = db_query($sql);
while (
$anode = db_fetch_object ($result)) {
$output .= "<li>" .l($anode->title , "node/$anode->nid")."</li>";
}
$output .= "</ul>";
return
$output;
?>

Display a list of the next (x) upcoming events

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* the following displays a list of the 10 upcoming event titles and
* links to their full event nodes. To increase/decrease
* the number of titles displayed..simply change the $listlength value
*
* Works with drupal 4.5.x and drupal 4.6
*/
  
$listlength= "10";
  print
event_block_upcoming($limit = $listlength);
?>

Display a list with last post w/links

This is a very useful code (at least for me). It shows a list of node types, node posts count, last post date and a link to the last node published.

<?php
$header
= array ('Content', 'Count', 'Last post date','Last post');
$rows = array();
$q = "SELECT n.type as tipo,count(n.type) as cant,max(DATE_FORMAT(FROM_UNIXTIME(n.changed ), '%Y-%m-%d')) as lastpost
FROM
{node} n
group by n.type"
;
$result = db_query ($q);
while (
$row = db_fetch_object ( $result ) )
{
  
$q = "SELECT max(n.nid) as max FROM {node} n where n.type='$row- >tipo'";
  
$result2 = db_query ($q );
  
$r = db_fetch_object ( $result2 );
  
$q = "SELECT n.nid as nid,n.title as title FROM {node} n where n.nid=$r->max";
  
$result2 = db_query ($q);
  
$r = db_fetch_object ( $result2 );
  
$link = l($r->title, "node/".$r->nid);
  
$rows[] = array ( 'data' => array ( t($row ->tipo), $row->cant ,$row->lastpost, $link  )) ;
}
if (!
$rows) {
  
$rows[] = array(array('data' => t('No log data available.'), 'colspan' => 2));
}
print
theme('table', $header , $rows);
?>

Display different page content to anonymous and authenticated users

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* The following simple snippet
* displays different information to anonymous/logged in users within a page.
*
* This works with drupal 4.5 and drupal 4.6
*/
global $user;
if (
$user ->uid) {
    return
"This message is only visible for logged-in users.";
}
if (!
$user->uid) {
    return
"This message is only visible for not-logged-in users." ;
}
?>

Display the (x) most recent nodes in full from a specific category

PLEASE NOTE! The following snippet is user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* This php snippet displays the most recent node in full
* from a specific category
*
* To increase/decrease the number of nodes listed
* change the $list_length value to suit.
*
* Works with drupal 4.6.x & 4.5.x
*
* Snippet submitted by Robert Garrigos (robertgarrigos)
*/
$taxo_id = 10;
$list_length = 1;
$sql = "SELECT * FROM node INNER JOIN term_node ON node.nid = term_node.nid WHERE term_node.tid = $taxo_id ORDER BY node.created DESC LIMIT $list_length" ;
$result = db_query($sql );
while (
$anode = db_fetch_object($result)) {
$output .= theme('node', $anode, $teaser = TRUE, $page = FALSE);
}
print
$output;
?>

Display the (x) most recent weblog entries from a specific user

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* the following displays a list of the 10 most recent weblog titles
* and links to the full weblogs of a certain user.
* If you want to increase/reduce
* the number of titles displayed..simply change the $listlength value
*
* for a different user change the $userid value
*
* works with drupal 4.6.
*
*/
$listlength="10";
$userid="8" ;
$output = node_title_list(db_query_range (db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = $userid AND n.status = 1 ORDER BY n.created DESC"), 0, $listlength));
print
$output;
?>

Display the (x) most recent weblog entries with teasers & info.

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* This php snippet displays the 10 most recent weblog entries with
* teaser & info.
*
* To increase/decrease the number of weblogs listed
* change the $listlength field to suit.
*
* Works with drupal 4.6
*/
  
$listlength= 10;
  
$result1 = pager_query(db_rewrite_sql ("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), variable_get('default_nodes_main', $listlength));
  while (
$node = db_fetch_object($result1)) {
    
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
  }
print
$output;
?>

Display/hide content from a specific IP address within a page

PLEASE NOTE These snippets are user submitted. Use at your own risk. For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* this Snippet allows you to display content ONLY to a visitor from
* a specific IP addresses in a page.
*
* Change the $allowed value to the IP address you want.
*
* This works with drupal 4.5 and drupal 4.6
*/
$allowed  = '100.100.100.100';
$userip = $_SERVER ['REMOTE_ADDR'];
if(
$userip == $allowed){
    print
"This content can only be viewed by the IP address you specify.";
}
?>

To reverse the situation and HIDE content to a user from a specific IP address

<?php
/**
* this Snippet allows you to hide content from a visitor at
* a specific IP addresses.
*
* Change the $hidden value to the IP address you want.
*
* This works with drupal 4.5 and drupal 4.6
*/
$hidden  = ' 100.100.100.100' ;
$userip = $_SERVER['REMOTE_ADDR' ];
if(
$userip != $hidden){
    print
"This content is displayed to everyone except the person from the IP address you specify." ;
}
?>

Insert a quicklist of recent forum topic titles and links

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* Creates a quicklist of recent forum topic titles and a link to their
* node.
*
* works and tested with 4.6
* does not work with 4.5
*
* To increase the length of the list, change $listlength
*
*/
$listlength="10" ;
$sql = "SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type='forum' ORDER BY l.last_comment_timestamp DESC";
$sql = db_rewrite_sql($sql);
$content  = node_title_list (db_query_range($sql, 0 , $listlength), t('Active forum topics:'));
if (
$content) {
  
$content .= '<div class="more-link">' . l(t('more'), 'forum', array('title' => t('Read the latest forum topics.' ))) .'</div>';
}
print
$content;
?>

Insert an image before the promoted nodes on the frontpage

The front_page module allows for the display of a customized front page. This PHP snippet keeps the original front page (containing nodes promoted to the front page) and inserts an image (or other static content) in front of it.

Prerequisite: front_page module must be installed and configured properly.
Go to ADMINISTER - SETTINGS - FRONT_PAGE, check "Allow embedded PHP code" and enter the PHP snippet into the "Front page HTML" box.

<center><img src="my_image.gif"></center>

<?php
   
print node_page_default();
?>

Tested with drupal version 4.6.0.

Insert the most recent poll

PLEASE NOTE! The PHP snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* the following displays the most recent poll
* and assumes you have the poll.module enabled
*
* Works with drupal 4.6
* Does not work with 4.5.x
*
*/
$sql = db_rewrite_sql( "SELECT MAX(n.created) FROM {node} n INNER JOIN {poll} p ON p.nid = n.nid WHERE n.status = 1 AND p.active = 1 AND n.moderate = 0");
      
$timestamp = db_result(db_query($sql ));
      if (
$timestamp) {
        
$poll = node_load (array('type' => 'poll', 'created' => $timestamp, 'moderate' => 0, 'status' => 1));
        if (
$poll->nid ) {
          
// poll_view() dumps the output into $poll->body.
          
poll_view( $poll, 1, 0, 1);
        }
      }
      print
$poll->body;
?>

maintenance redirect: automatically redirecting everyone but you away from the drupal site

PLEASE NOTE! The following snippet is user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* This php snippet redirects everyone but you away from the drupal site
* to a htm page. Useful for "undergoing maintenance" type occasions
*
* put this snippet at the very top of your INDEX.PHP file in your root drupal folder
* or in your front_page settings page and place your closed.html
* file in the same folder.
*
* change the your_ip address to be your IP address so you can still access the site
*
*/
$your_ip = '100.100.0.1 ';
if (
$_SERVER['REMOTE_ADDR'] != $your_ip) {
  
header ('location:closed.html');
}
?>

Printing PHP variables from GET or POST forms

PLEASE NOTE These snippets are user submitted. Use at your own risk. For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**
* this Snippet illustrates how you display the values of a submitted form
* in a Drupal page.
*
* Submitted by puregin
*
* This works with drupal 4.5 and drupal 4.6
*/
print "variable1: " . $_POST["variable1"] ."<br/>";
print
"product: " . $_POST["product"] . "<br/>";
print
"size: " . $_POST[ "size"] ."<br/>";
?>

NOTES:

Change $_POST to $_GET if you used GET as your form method or if you are using a URL to set the variables. (e.g., example.com/page.php?variable1=hello )

Using more than one php snippet in the same node (or front_page)

In some circumstances, if you are using two or more php snippets in the same node - or on your front_page.module page - you need add the following line at the beginning of each php snippet you intend to use

<?php
unset ($output);
?>

why?

The reason is to avoid the problem of using the return $output; more than once in the same node. The return $output command will end the reading of code and all subsequent code or text in that node (or front_page) will be ignored.

To avoid potential problems, rather than return $output;, you can use...

<?php
print $output;
?>
...for the last line of code.

But...

With each subsequent php-generated list you create in that same node (or front_page), you will get a cumulative list -- the content generated by each additional php snippet will be added to the $output list. (For example, the second php snippet's list of posts on "apples" would be added to the first php snippet's list of posts on "oranges," when what you really want is just a list of posts on "apples.")

So how would one "clear" the output results so one can have another php snippet creating output? Start each of your subsequent snippets of php code with this:

<?php
unset ($output);
?>

This will clear the previous results so that your 2nd, 3rd ... nth list will have unique results relevant to its own query.

Thus you will be able to have several php-generated outputs on the same page (such as lists of recent posts in several different taxonomy terms) without conflict or intermingling of results.

Cresce la pressione sui musulmani italiani



Cresce la pressione sui musulmani italiani

Cresce la pressione sui musulmani italiani dopo la seconda
ondata di attentati a Londra. Due giorni fa Khaldi Samir,
l'imam della moschea di Al Huda, nel quartiere romano di
Centocelle, si è visto arrivare a casa, alle sette di
mattina, dieci agenti della polizia in borghese con un
mandato di perquisizione. Per tre ore hanno perlustrato da
cima a fondo l'appartamento di Latina dove Samir abita con
la moglie e i figli, e hanno scaricato la rubrica
telefonica dal suo cellulare. Gli agenti hanno spiegato che
stavano cercando degli indizi sugli attentati di Londra, ma
il mandato di perquisizione non indicava che l'imam era
sospettato. "Lo stato sta punendo i suoi migliori contatti
con il mondo musulmano: non ce lo saremmo mai aspettati
dall'Italia", ha commentato Samir.

International Herald Tribune, Francia



Pressure is growing on Muslims in Italy
By Elisabeth Rosenthal International Herald Tribune
MONDAY, JULY 25, 2005

ROME As a second wave of London bomb attacks hit the news Thursday, Imam Khaldi Samir clicked nervously at his office computer, next to the prayer hall at the Alhuda Islamic Cultural Association on the outskirts of Rome. Bombs in London, he has seen, produce fallout for him.
 
Just two days earlier, with Italy stepping up surveillance after the first round of London attacks, 10 plainclothes police officers with a search warrant turned up at 7 a.m. at the imam's home in Latina, 70 kilometers, or 40 miles, south of Rome. During a three-hour raid, while his children slept, they scoured the home he shares with his Italian wife, and then downloaded numbers from his cellphone.
 
The police explained that they were looking for clues related to the London bombings, although they found nothing, said the imam, who preaches to up to 800 mostly poor immigrant worshipers each week. The search warrant did not indicate that the imam himself was suspected of a crime. Instead, the police politely explained, the search was "preventive" - the warrant stating he might have "unknowingly" had contact with people connected to terrorism. Five other leaders of the Italy's Muslims were searched the same day, he said.
 
"The state is punishing its best links to the Muslim community - we never expected that the Italian state would do something like this," said Samir, a soft-spoken man in a shirt and slacks, clearly shaken by the course of events.
 
"Every day I stress the need for moderation and integration," Samir said, "but these searches bring into question my credibility in our community. People will say, 'This is your payback for your moderation.'"
 
He said such events served to radicalize young people.
 
As antiterrorism officials across Europe are intensifying their hunt to root out sleeper cells, they walk a delicate line between thwarting terrorists and radicalizing innocent Muslims who are already largely isolated and marginalized in many European nations.
 
The challenge of controlling terrorism without creating new terrorists, is particularly acute in countries like France and Italy.
 
In those two countries, large and growing Muslim populations are kept by law and by custom on the fringes of mainstream society. There are an estimated 1.5 million Muslims in Italy, a country of about 58 million people. The vast majority of the Muslims are immigrants, who have little chance of getting citizenship. Less than 10 percent have an Italian passport.
 
An official at Italy's law enforcement agency, the Ministry of the Interior, said that he did not know specifics of recent raids, but that he was "not surprised" that such searches were occurring. "This is an ongoing process," he said.
 
On Friday, Italy's Council of Ministers adopted a series of new antiterrorism provisions, which are likely to take effect soon. These include new registration requirements for Internet cafés and cellphone users, new limits on pilots licenses, and quick expulsions for foreigners considered a danger to national security or who assist in terrorist activities.
 
But the search on the imam's house occurred legally under the current rules, which give judges wide leeway in issuing warrants.
 
"What if I had reason to believe that a terrorist had gone to your house and was worried he left something - some documents or even a suitcase?" said a senior Italian antiterrorism official, explaining the search.
 
In 2001, the police searched the Alhuda center, which includes a prayer hall and a cultural center and where Arabic and Islamic culture are taught to children. Last year, they searched the home of Ben Mohamed Mohamed, the center's president.
 
But since the attacks in London, the Italian government has beefed up security measures and has also attempted to reach out to Muslims. In Michelangelo's beautiful Campidoglio, on the afternoon of the second London bombings, the city of Rome invited prominent Muslims to convey a message of coexistence.
 
"Rome is a city that it open to everybody," said Giuseppe Mannino, chairman of the City Council. "You are our brothers."
 
He shared the podium with Mahmoud Hammad Sheweita, imam of Rome's only official mosque, the Grand Mosque - an architectural masterpiece filled with light and soaring arches, which operates with the permission and cooperation of the Ministry of the Interior.
 
Samir and Mohamed listened from the back row.
 
Unlike the Alhuda center, a subterranean former warehouse where young men wander in and out all day, the luxurious official mosque is open to worshipers only on Friday.
 
For the rest of the week, its primary function is to serve as a sort of liaison between Islam and the Italian government. From here, Mario Scialoja, a former Italian diplomat and convert to Islam, who is head of the Italian branch of the World Muslim League, meets with Islamic ambassadors and lobbies Italian politicians, pushing them to allow Muslims better access to citizenship, and religious education for Muslim children.
 
Scialoja said that the worshipers in his mosque, filled on Fridays, were typical Italian Muslims - poor immigrants who come to Italy for a better existence.
 
He said that "99.7 percent of them couldn't care less about fundamentalism" and that only 4 percent of Italy's Muslims attend mosque on a regular basis.
 
While he has noted some acts of intolerance since the London bombings, he praised Giuseppe Pisanu, the interior minister, whom he meets with regularly, and he called Italy's new antiterrorism proposals "very responsible." And though he blames the U.S. invasion of Iraq for creating terrorism, he does not support an immediate withdrawal. Italy has troops in Iraq in support of the U.S.-led invasion.
 
"To stay is to feed this anger, but to leave now would create a mess," he said.
 
But his official version of Islam seems to have little resonance or even connection with Samir's prayer hall, where many worshipers speak halting Italian and the lingua franca is Arabic.
 
When Scialoja tried to form a national association of Muslim groups five years ago, "the experiment was a failure," he said, "since some groups had views I couldn't support."
 
In 2003, when the Grand Mosque expelled its new Imam for a fiery sermon that justified Palestinian bombings in Israel (though not in Italy), Alhuda's Web site posted an article defending his right to free speech.
 
In part because Italy does not recognize Islam as a religion, Samir's flock does not have a real mosque. Italian Muslims must work on their religion's holy days. As aliens, the vast majority have no right to vote.
 
"Now, with the increasing security, they search our houses - this is a very bad sign," Samir said. "We hear all about the policies on integration, but we never seen any concrete measures."
 
They remain largely outsiders and, especially now, visitors to the Alhuda center and the surrounding Islamic shops were greeted with intense suspicion. Requests to interview the Imam were met with deflections and questions: Where are you from? Why do you want him?
 
Samir, a Tunisian who has lived in Italy for 15 years, insists that he would report suspicious activity to the police.
 
Asked if anyone from the Alhuda had attended the religious schools in Pakistan that have been a breeding ground for terrorists, he said: "Not that I know of, but they certainly wouldn't tell me if they had."