marquee only for news

fabrizioprocopio - December 20, 2008 - 04:26
Project:Last Node
Version:6.x-2.3
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Hi, in a site of mine I need to show the scrolling text block only for one content type (news/story). There is a way to get this result?

thanks

#1

TheCrow - January 5, 2009 - 18:36

The most simple way is to add this code in the _last_node_contents function:
In the example the node type is story:

<?php
function _last_node_contents($which_block = '0') {

  if (
$which_block == '3') {
   
$node = 'story';
   
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.type in '%s' AND n.status = 1 ORDER BY n.created DESC"), $node, 0, 10);
    while (
$node = db_fetch_object($result)) {
     
$output .= l($node->title,'node/'. $node->nid) ."<br />-<br />";
    }
   
   
$output = '<marquee id="last_node-block" direction="up" scrollamount="1" scrolldelay="1" onMouseOver="this.stop()" onMouseOut="this.start()">'. $output .'</marquee>';
   
drupal_add_css(drupal_get_path("module","last_node") ."/last_node.css");
    return
$output;
  }

  ...
?>

#2

fabrizioprocopio - January 5, 2009 - 22:21

EN:
Thanks a lot,
the problem is that I don't know php.
Can you explain particularly where put the code you posted?

-------------------------------------------
IT:
Ti ringrazio, il problema è che io non conosco il php,
potresti spiegarmi un po' più banalmente dove copiare e incollare il codice che hai postato?

ti ringrazio molto
fabrizio

#3

TheCrow - February 11, 2009 - 12:32

nel file last_node.module, dovresti trovare quella funzione descritta, se ti può servire una guida di base alla creazione di moduli dove specifico la parte relativa ai blocchi. :))

#4

fabrizioprocopio - February 11, 2009 - 18:58

Grazie davvero!

fabrizio :-)

#5

amalrajsj - May 6, 2009 - 05:49

Dear Crow,
I happened to see your comments about the marquee function. Could you be kind enough to tell me about how to use the function in my home page alone? I do not want the node to be displayed. Just some text, which is often changed, should be displayed in the home page. I am using drupal 6.9 version for my site. If there are some modules to perform this function please let me know. I want a simple marquee function with a facility to upload the text context. I would be grateful to your contribution.

Thanking you in advance,
AAR

#6

TheCrow - May 6, 2009 - 09:08

this block is the basic for display the last 10 titles belonging to story type without need any other module:

<?php
    $node
= 'story';
   
   
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title FROM {node} n WHERE n.type in '%s' AND n.status = 1 ORDER BY n.created DESC"), $node, 0, 10);

    while (
$node = db_fetch_object($result)) {
     
$output .= l($node->title,'node/'. $node->nid) ."<br />-<br />";
    }
  
   
$output = '<marquee direction="up" scrollamount="1" scrolldelay="1" onMouseOver="this.stop()" onMouseOut="this.start()">'. $output .'</marquee>';
   
    print
$output;
?>

i leaved the code for add the css and format the text for keep it clear... using front page module you can paste and adjust it for have your personal home page... otherwise you can paste it inside a block and show it in the region you want (depend from the theme). Just remember to enable the PHP filter.

If you need more simply snippets watch too here.

For more complex and generic use Views module represent the big approach for make any kind of SQL query at your database... it's not so easy to use if you start just now with Drupal but is very powerfull and much documented... could be the answer to your question!

#7

WiFier - June 1, 2009 - 19:18

Thank you, sounds good..
but I couldn't make it work on my drupal it returns the same code in the blok.

Could any one please help making it work?

#8

TheCrow - June 3, 2009 - 08:27

what code you referrer? #6 or #1?

The #1 is just a part for expand last_node module but it's not complete... need integrate with the tutorial hint for show the new block into the 'admin block' page...

#6 is a stand alone code... doesn't need any other module, just past it into a block u create from zero and modify it for your needs... don't forget to do a preview before save it...

#9

Appelflapje33 - October 30, 2009 - 17:12

When I paste the PHP code (from post #6) in a block i get the following error:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''nieuws' AND n.status = 1 ORDER BY n.created DESC LIMIT 0, 10' at line 1 query: SELECT n.nid, n.title FROM node n WHERE n.type in 'nieuws' AND n.status = 1 ORDER BY n.created DESC LIMIT 0, 10 in ***/includes/common.inc(1685) : eval()'d code on line 4.

HELP?

 
 

Drupal is a registered trademark of Dries Buytaert.