Welcome to Geeklog, Anonymous Monday, December 23 2024 @ 06:13 pm EST

Geeklog Forums

Limiting rss stories in portal block

Page navigation


switched

Anonymous
hi. I\'ve switched from postnuke and I\'m really happy with geeklog so far. However, I\'ve noticed that there isn\'t a way to limit the number of rss stories that show up in a portal block as I was able to do with postnuke. Is there even a way to hack a file to achieve this? I\'m not that technically inclined to figure it out myself but if someone can tell me what to do, I\'d like to try it. I just upgraded from 1.3.7 to 1.3.8 by the way. Thanks.
 Quote

Status: offline

squatty

Forum User
Full Member
Registered: 01/21/02
Posts: 269
Here's a quick hack to limit the number of links.... Replace the code in lib-common.php COM_rdfImport with the following:
Text Formatted Code

if( !$rdferror )
        {
            $blockcontent = COM_makeList( $RDFheadlines );
            // Limit News Links to 5
            $RDFHeadlines = array_splice($RDFheadlines,5);              
            $blockcontent = preg_replace( "/(

In a world without walls and fences, who needs Windows and Gates?
 Quote

Status: offline

squatty

Forum User
Full Member
Registered: 01/21/02
Posts: 269
Well, that didn't work.

Change this:
$RDFheadlines = array();

To this:
$RDFHeadlines = array_splice($RDFheadlines,5);

Set the '5' to the number of links you want to display.
In a world without walls and fences, who needs Windows and Gates?
 Quote

switched

Anonymous
hmm... thanks for the quick response.. it didn\'t work though. I tried both, including only changing that one line. Still didn\'t work. Is it working for you?
 Quote

switched

Anonymous
hey squatty, in your second post, were you still referring to the same section in the COM_rdfImport function from your first post? Because I\'m noticing that the line: $RDFheadlines = array(); shows up in earlier in that same function like this: $RDFinsideitem = false; $RDFtag = \'\'; $RDFtitle = \'\'; $RDFlink = \'\'; $RDFheadlines = array(); and it also shows up like that in COM_rdfCheck, thus confusing me. Did you mean for me to change every instance where that line shows up, or only a specific instance in a specific function? Thanks for all your help.
 Quote

Status: offline

squatty

Forum User
Full Member
Registered: 01/21/02
Posts: 269
Yes, it does work for me. You only need to update the code in COM_rdfImport. That\'s where the display and store logic is. Be sure to delete any saved feeds in your DB. The update will only show if the feed is out of date (and thus needs to be updated) or if it is new. The code in my lib-common looks like this: if( !$rdferror ) { $RDFHeadlines = array_splice($RDFheadlines,5); $blockcontent = COM_makeList( $RDFheadlines ); ---SNIP---- If that doesn\'t work, try this.
In a world without walls and fences, who needs Windows and Gates?
 Quote

switched

Anonymous
Not sure why but it still doesn\'t work for me. Sorry for not completely understanding this but what does this mean exactly?: \" Be sure to delete any saved feeds in your DB. The update will only show if the feed is out of date (and thus needs to be updated) or if it is new.\" Do you mean I should delete lib-common.php from the server and re-upload it? I just don\'t know enough to know what the \"feed\" you\'re referring to is. Also, does the news plugin work in a side block? And just in case I\'m doing something silly, I\'ll paste a section from my lib-common.php: function COM_rdfImport( $bid, $rdfurl ) { global $_TABLES, $RDFinsideitem, $RDFtag, $RDFtitle, $RDFlink, $RDFheadlines; $RDFinsideitem = false; $RDFtag = \'\'; $RDFtitle = \'\'; $RDFlink = \'\'; $RDFheadlines = array(); $update = date( \"Y-m-d H:i:s\" ); $result = DB_change( $_TABLES[\'blocks\'], \'rdfupdated\', \"$update\", \'bid\', $bid ); clearstatcache(); $rdferror = false; $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, \'COM_rdfStartElement\', \'COM_rdfEndElement\'); xml_set_character_data_handler( $xml_parser, \'COM_rdfCharacterData\' ); if( $fp = @fopen( $rdfurl, \'r\' )) { $startoffeed = true; while( $data = fread( $fp, 4096 )) { if( $startoffeed ) { $data = ltrim( $data ); $startoffeed = false; } if( !xml_parse( $xml_parser, $data, feof( $fp ))) { $errmsg = sprintf( \"Parse error in %s: %s at line %d\", $rdfurl, xml_error_string( xml_get_error_code( $xml_parser )), xml_get_current_line_number( $xml_parser ) ); COM_errorLog( $errmsg, 1 ); $rdferror = true; $result = DB_change( $_TABLES[\'blocks\'], \'content\', addslashes ($errmsg), \'bid\', \"$bid\" ); break; } } fclose( $fp ); xml_parser_free( $xml_parser ); if( !$rdferror ) { $RDFHeadlines = array_splice($RDFheadlines,5); $blockcontent = COM_makeList( $RDFheadlines ); $blockcontent = preg_replace( \"/(
 Quote

switched

Anonymous
... continued from above post:

\015\012)|(\015)|(\012)/", "", $blockcontent );
$result = DB_change( $_TABLES['blocks'], 'content', "$blockcontent", 'bid', $bid);
}
}
else
{
$rdferror = true;
COM_errorLog( "Can not reach $rdfurl", 1 );

$result = DB_change(
$_TABLES['blocks'],
'content',
"GeekLog can not reach the supplied RDF file at $update. "
. "Please double check the URL provided. Make sure your url is correctly entered and it begins with "
. "http://. GeekLog will try in one hour to fetch the file again.",
'bid',
"$bid"
);
}
}
 Quote

Status: offline

squatty

Forum User
Full Member
Registered: 01/21/02
Posts: 269
Do you mean I should delete lib-common.php from the server and re-upload it? I just don\'t know enough to know what the \"feed\" you\'re referring to is.
No, your lib-common.php updates look correct. What I mean by \"delete the feed\" is delete your portal block. Then create a new portal block with the same RSS/RDF URL. The code will not work on your existing block. The data (\"feed\") is already saved with the full set of links.
Also, does the news plugin work in a side block?
Yes, the news plugin looks the same as a portal block. With the exception that a user can select one of many RSS/RDF feeds to display in the block. The site admin configures which RSS/RDF feeds a user can select from. You can see the plugin in action on my site: www.squatty.com.
In a world without walls and fences, who needs Windows and Gates?
 Quote

switched

Anonymous
You know what? Silly me. It works now. The update on lib-common worked. I just opened the site in a different browser and there it was. I guess it was just a browser cache thing or something. Thanks squatty! Back to being a happy geeklogger.
 Quote

Status: offline

RickW

Forum User
Full Member
Registered: 01/28/04
Posts: 240
Location:United States
sore
I want to do this same thing... and I was just about to change that line that squatty pointed out... then I realized this is going to be global to all portal blocks. I need to customize them though.

So my Virus Alerts rss feed will be whatever the feed gives me, then some of my other news based feeds will only be 3 links, then one other article feed will be limited to 5 links... etc...

Any solution ideas? Maybe something to be added in the next build?
www.antisource.com
 Quote

Status: offline

Kutulu

Forum User
Newbie
Registered: 06/04/04
Posts: 6
Quote by squatty: Well, that didn't work.

Change this:
$RDFheadlines = array();

To this:
$RDFHeadlines = array_splice($RDFheadlines,5);

Set the '5' to the number of links you want to display.


Worked like a champ! You da man Squatty!
 Quote

Status: offline

RickW

Forum User
Full Member
Registered: 01/28/04
Posts: 240
Location:United States
Quote by squatty: Well, that didn't work.

Change this:
$RDFheadlines = array();

To this:
$RDFHeadlines = array_splice($RDFheadlines,5);

Set the '5' to the number of links you want to display.


I just tried to do this, but that didn't work for me. I still get the same number of RSS links. Sad
www.antisource.com
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
In Geeklog 1.3.10, if you have a look at function COM_rdfImport in lib-common.php, you'll see this line:
Text Formatted Code
$maxheadlines = 0; // set to something > 0 to limit max. number of headlines
 

Guess what it does ...

bye, Dirk
 Quote

Status: offline

RickW

Forum User
Full Member
Registered: 01/28/04
Posts: 240
Location:United States
Quote by Dirk: In Geeklog 1.3.10, if you have a look at function COM_rdfImport in lib-common.php, you'll see this line:
Text Formatted Code
$maxheadlines = 0; // set to something > 0 to limit max. number of headlines

 

Guess what it does ...

bye, Dirk


Yay, an early christmas present. Mr. Green

I haven't switched over to 1.3.10 yet because I want to give it some time to make sure all of the after-release bugs and security holes are worked out since a lot of new features were added. Plus I'm waiting to see what Blaine cooks up for his next forum release, I'll probably upgrade both at the same time...
www.antisource.com
 Quote

Status: offline

frisco3

Forum User
Junior
Registered: 02/06/04
Posts: 23
Location:Burlington Vermont
I used this option today and it worked great! Just a FYI though, I did have to recreate the block from scratch after I changed the setting in lib_common. Not a big deal, but it wasn't working otherwise. I changed the 10 headline RSS to a 5 headline RSS from Yahoo News. This rocks! Big Celebration

Brian Brown
www.iburlington.com
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Simply saving the block again would have done the trick, too. The RSS feeds are stored in the database and only refreshed once per hour. By saving the block again, you force it to refresh.

bye, Dirk
 Quote

drali

Anonymous
hey
spent days trying to figure this out...to no avail.

until today!



Text Formatted Code
if( !$rdferror )
        {
            $RDFheadlines = array_splice($RDFheadlines,5);
            $blockcontent = COM_makeList( $RDFheadlines );
            $blockcontent = preg_replace( "/(1512)|(15)|(12)/", '',
                                          $blockcontent );

 


the default FOR ME had this:

Text Formatted Code
if( !$rdferror )
        {
            $blockcontent = COM_makeList( $RDFheadlines );          
            $RDFheadlines = array_splice($RDFheadlines,5);
            $blockcontent = preg_replace( "/(1512)|(15)|(12)/", '',
                                          $blockcontent );

 



The FIRST ONE is right.
notice the ORDER of the $blockcontent and $rdfheadlines...!!!
i changed it...as was mentioned...but because it was being changed AFTER it would not work.

Yah, this is probably simple for most ppl...but it was a big deal for me!

Hope this helps someone who may run into a similar problem!
 Quote

drali

Anonymous
okay, seems like there are some issues.

i thought i had it going...but...it only does it on the first block properly (yes, i've killed the blocks, added new ones, etc)

AND

it limits it to the LAST url in the RSS feed. ie., it shows the OLDEST ones...not the NEWEST ones!
 Quote

drali

Anonymous
Quote by drali: okay, seems like there are some issues.

i thought i had it going...but...it only does it on the first block properly (yes, i've killed the blocks, added new ones, etc)

AND

it limits it to the LAST url in the RSS feed. ie., it shows the OLDEST ones...not the NEWEST ones!


i found that it actually GETS RID OF the specified number from the RSS feed.

ie, the 'array splice' thing doesnt limit the feed entries...it gets rid of that number of entries.

any ideas?
 Quote

Page navigation

All times are EST. The time is now 06:13 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content