[drupal-docs] New php snippets page

Laura Scott laurascott at mailspot.org
Fri Jun 3 20:45:34 UTC 2005


Maybe I did not word it well. Dublin Drupaller seemed to love it, though 
-- this was a child page to the section he created. Here is an example 
where the code would be needed:

> <h3>recent posts on DVD authoring</h3>

> <?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 = 34;
> $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>";
> print $output;
> ?>
> </div><!--end fpbox_dvd-->
> <div class="fpbox" id="fpbox_integratedweb">
> <a href="services/web-services-your-way"><img 
> src="system/files?file=images/front-integrated.gif" alt="Integrated 
> web" title="A turnkey solution for the busy professional" /></a> <br />
> <a href="services/web-design">Web design</a><br />
> <a href="services/web-hosting">Web hosting</a><br />
> <a href="about/2005/03/05/why-open-source">Why Open Source?</a><br />
> <a href="about/our-partners-resources-and-affiliations">Our Partners</a>
> <a href=""></a>
> <h3>recent posts on web design and development</h3>
> <?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
>  */
> unset ($output);
> $taxo_id = 27;
> $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>";
> print $output;
> ?>
> </div>


I would guess that it would only make sense if you ran into a situation 
where you were trying to put more than one php snippet into a single node.

Laura


Liza Sabater wrote:

>Hi Laura,
>
>I'd like to see a page where you use this. I unfortunately don't get in 
>which situation I should be using this. Please keep in mind that there 
>may be a lot of designers out there who are not PHP literate BUT have 
>hacked away at templates elsewhere.....
>  
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://drupal3.drupal.org/pipermail/documentation/attachments/20050603/4ecc41e6/attachment.htm


More information about the drupal-docs mailing list