[support] Showing last 4 news is in homepage but in center not in blocks

Effennel effennel at gmail.com
Sat Jun 24 19:46:11 UTC 2006


Here is a bit of code that my set you a good path. I use it in a block 
myself, but I can see why you wouldn't be able to insert in in your home 
page template.

It's actually an adaptation from http://drupal.org/node/23232. In this 
case, the scripts displays the fist 80 characters (actually cuts after a 
complete word within the first 80 characters) of items with taxonomy ids 
21 and 27.

<?php
/**
* Creates a list of node titles selected from multiple category terms
* in descending chronological order (most recent first).
* Titles link to full node.
*
* To change category terms to select from,
* edit the $taxd_id numbers, retaining the "" marks.
*
* To change the number of node titles, edit the $list_no number.
*
* This snippet is tested with Drupal 4.6.x
*
*/
$taxo_id = "26, 27";
$list_no =3;
$query = "SELECT DISTINCT(n.nid), n.title, n.teaser, n.created FROM 
{node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid in 
($taxo_id) AND n.status = 1 ORDER BY n.created DESC LIMIT $list_no";
$sql = db_rewrite_sql($query);
$result = db_query($sql);
$items = array();
while ($anode = db_fetch_object($result)) {
   $blurb = strip_tags($anode->teaser);
   $i= 80;
   $blurb = substr($blurb , 0, $i); //take the first 80 characters
   while($i >= 0){	//cuts the blurb at the end of the last complete word
     if(!ereg(' $', $blurb)){
       $i--;
       continue;
     }
     break;
   }
   $items[]= l("<span class=\"newsdate\">" . 
format_date($anode->created, $type = 'custom', $format = 'd.m.y') . 
"</span><br />" . $anode->title . "<br />" . $blurb  . "...<br /><span 
class=\"newsmore\">MORE&nbsp;&nbsp;&nbsp;</span>", "node/$anode->nid", 
array(), NULL, NULL, FALSE, TRUE);
}


if(count($items)) {
   return theme('item_list',$items);
}
?>

Francis

bunset at dconsultia.es wrote:
> Hi!
> I want to show last 4 news of my CCK type called "news" but in center of
> homepage, not in blocks, inside the node I mean, so I need a php code to
> show it, I was trying but nothing
> Anybody knows ?
> 
> Bye for now,
> David from Dconsultia.es 
> 
> 
> -----Mensaje original-----
> De: bunset at dconsultia.es [mailto:bunset at dconsultia.es] 
> Enviado el: sábado, 17 de junio de 2006 4:28
> Para: 'support at drupal.org'
> Asunto: showing last 4 news
> 
> Hi!
> I have created a new content type with CCK called "news", I am trying show
> in home page last 4 news but I don’t get the correct snippet for it.
> Anybody can guided me please?
> Regards,
> 
> David from dconsultia.es (Spain)
> 
> 
> 
> -----Mensaje original-----
> De: support-bounces at drupal.org [mailto:support-bounces at drupal.org] En nombre
> de support-request at drupal.org
> Enviado el: viernes, 16 de junio de 2006 14:00
> Para: support at drupal.org
> Asunto: support Digest, Vol 42, Issue 21
> 
> Send support mailing list submissions to
> 	support at drupal.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.drupal.org/listinfo/support
> or, via email, send a message with subject or body 'help' to
> 	support-request at drupal.org
> 
> You can reach the person managing the list at
> 	support-owner at drupal.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of support digest..."
> 
> 
> Today's Topics:
> 
>    1. Drupal-Postgres-LDAP-FreeBSD (David King)
>    2. Re: theme search box button next to field (Franz Iberl)
>    3. Re: Menus (Pherowze)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Thu, 15 Jun 2006 19:27:59 -0700
> From: David King <dking at ketralnis.com>
> Subject: [support] Drupal-Postgres-LDAP-FreeBSD
> To: support at drupal.org
> Message-ID: <D1FCD04C-F3B3-43FB-88E8-E120F65147CF at ketralnis.com>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
> 
> My name is David King, I am having trouble with LDAP users logging on
> 
> I have a very vanilla Drupal (v4.6.6) install, except that it is  
> installed on Postgres, I have the LDAP authentication module  
> installed, and it is installed on FreeBSD (all three are installed  
> via the FreeBSD Ports system).
> 
> When I try to have an LDAP user log in, the user is created in the  
> database, and looks like this:
> 
> $ psql drupal
> drupal=# select uid,name,data from users;
> uid | name   
> |                                                             data
> -----+------- 
> +----------------------------------------------------------------------- 
> --------------------------------------------------------
>     0 |       |
>     1 | admin | a:1:{s:5:"roles";a:1:{i:0;s:1:"2";}}
>     2 | dking | a:3:{s:5:"roles";a:1:{i:0;s:1:"2";}s: 
> 17:"ldap_authentified";b:1;s:7:"ldap_dn";s:38:"<censored=DN>";}
> (3 rows)
> 
> But the user is presented with a blank page after several seconds. In  
> the log are dumped many (a hundred or so) Postgres errors of the  
> following forms:
> 
> pg_query(): Query failed: ERROR: multiple assignments to same column  
> "changed" in /usr/local/www/drupal/includes/database.pgsql.inc on  
> line 45.
> 
> query: UPDATE users SET uid = '2', name = 'dking', pass =  
> '47c6b15aca93873f58522f26300d181d', mail = 'dking@<censored=domain>',  
> mode = '0', sort = '0', threshold = '0', theme = '', signature = '',  
> created = '1150424378', changed = '1150424378', status = '1',  
> timezone = '', language = '', picture = '', init = '', data = 'a:3:{s: 
> 5:"roles";a:1:{i:0;s:1:"2";}s:17:"ldap_authentified";b:1;s: 
> 7:"ldap_dn";s:38:"<censored=dn>";}', data = 'a:3:{s:5:"roles";a:1:{i: 
> 0;s:1:"2";}s:17:"ldap_authentified";b:1;s:7:"ldap_dn";s: 
> 38:"<censored=dn>";}', changed = 1150424379 WHERE uid = 2 in /usr/ 
> local/www/drupal/includes/database.pgsql.inc on line 62.
> 
> The errors seem to alternate between those two.
> 
> I can't delete the user in the database, because if I go to  
> Administer > Users > dking (the username) > Edit, I get the browser  
> error that the server has closed the connection.
> 
> How can I go about troubleshooting/debugging this? Does anyone have  
> any ideas?
> 
> Some more potentially useful information:
> 
> ~% uname -a
> FreeBSD <> 5.3-RELEASE-p20 FreeBSD 5.3-RELEASE-p20 #2: Fri Sep  9  
> 14:11:12 PDT 2005     root@<>:/usr/obj/usr/src/sys/ROUTERKERNEL  i386
> 
> ~% pkg_info | grep drupal
> drupal-4.6.6_2006031700 CMS that supports pgsql and mysql
> drupal-ldap_integration-4.6.0_20060117 LDAP user authentication for  
> the Drupal CMS
> 
> ~% psql --version
> psql (PostgreSQL) 8.0.8
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Fri, 16 Jun 2006 08:37:13 +0200
> From: Franz Iberl <f.iberl at amazonas-box.de>
> Subject: Re: [support] theme search box button next to field
> To: support at drupal.org
> Message-ID: <d56558947547037902b3c5585a99fb38 at amazonas-box.de>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Hello again,
> 
> 
>> I know the code is correct.  It displays correctly in this node:
>>http://www.animecards.org/node/74
> 
> 
> ok, the button 'submit' which fits in the node obiously does not fit in 
> the orange box at the left side.
> 
> 
>> #search .form-text {
>>     width: 8em;
>> float: left
>> }
> 
> 
> try e.g. 5em ?
> 
> in a hurry
>    Franz
> 
> 



More information about the support mailing list