Difference between revisions of "News Block"

From GeeklogWiki
Jump to: navigation, search
 
m (Added category)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
;[[Introduction]]
+
= Introduction =
;[[Features]]
+
 
;[[List of files with descriptions]]
+
The '''Headline News''' block is a Geeklog phpblock for displaying links to featured news stories made available from ANY RDF/RSS compatible content feed.  Included in the source code is a list of many popular RDF/RSS feeds.  These feeds are available for public use on Moreover: 
;[[Instructions - New install]]
+
http://w.moreover.com/categories/category_list_xml.html.
;[[Notes]]
+
 
;[[Changes]]
+
 
 +
= Features =
 +
 
 +
Headline News block features are as follows:
 +
 
 +
* Displays links to stories for RDF/RSS compatible news feeds.  The block utilizes the same code base as the standard Geeklog Portal block.
 +
* Consists of four views:  default view, detailed view, category view, and administration view:
 +
** Default view is the main phpblock view (home page block).  Registered users can customize the news provider.  Anonymous users will receive the default provider set by the news administrator.
 +
** Detailed view is a secondary view where users can view specific feeds before setting their default provider.
 +
** Category view is a secondary view where users can view specific feeds sorted by category.
 +
** Administration view is where a user configures his/her default news feed and where the site news admin sets the default news feed.  The news admin can also add, update, or delete RDF/RSS feeds.
 +
* Has built in MySQL caching.
 +
* Has a built in block timer for measuring the execution time of the block.
 +
 
 +
 
 +
= List of files with descriptions =
 +
 
 +
{| border=1 cellspacing=0
 +
!FILE:
 +
!DESCRIPTION:
 +
|-
 +
| /path/to/geeklog/public_html/news/display_news.php
 +
| Core phpblock.
 +
|-
 +
| /path/to/geeklog/public_html/news/news_details.php
 +
| View specific feeds before setting default provider.
 +
|-
 +
| /path/to/geeklog/public_html/news/top_news.php
 +
| Top news feeds.
 +
|-
 +
| /path/to/geeklog/public_html/news/admin.php
 +
| News administration page.
 +
|}
 +
 
 +
 
 +
= Instructions - New install =
 +
 
 +
# Extract the code to /public_html.<br>A new directory named "news" will be created for you.
 +
# Run the SQL script:  news-sql.sql<br>The script will create one new table named gl_newsblock and make updates to gl_userprefs and gl_groups tables. 
 +
# Add the following to the /path/to/geeklog/system/lib-database.php<br>--- CODE BEGINS ---<br>$_TABLES['newsblock'] = $_DB_table_prefix . 'newsblock';<br>--- CODE ENDS ---
 +
# Add the phpblock:  news.phpblock
 +
## The first step is to add the contents of news.phpblock to lib-custom.php.
 +
## The second step is to simply create the phpblock and reference the phpblock_getnews function.
 +
# Set the default news provider for anonymous or guest users:
 +
## First add your admin user to the "News Admin" group. Do this via the Geeklog user administration.
 +
## Second, login as the admin user and click the "Edit" link on the news block. You will be presented with options for setting the global default news provider.
 +
## Select the appropriate links to set the defaults.
 +
 
 +
 
 +
= Notes =
 +
 
 +
* If the block display looks off (bad alignment, incorrect content, ect).  Delete the news_cache and set news_cache_expire = 1 for the suspect user (uid 1 = anonymous) in gl_userprefs.  This will re-paint the block with updated content.
 +
* The block also has a built in timer.  To enable the timer, uncomment the following lines in lib-custom.php:
 +
 
 +
<pre>
 +
//$_NEWS_TIMER = new timerobject();
 +
//$_NEWS_TIMER->startTimer();     
 +
</pre>
 +
 
 +
;AND uncomment the lines in display_news.php
 +
 
 +
<pre>
 +
//$boxtitle.= "<small><br>Created this block in <b>";
 +
//$boxtitle.= $_NEWS_TIMER->stopTimer();
 +
//$boxtitle.= "</b> seconds.</small>";
 +
</pre>
 +
 
 +
* You can adjust the cache values by editing the display_news.php file.  By default, cache is stored for 30 minutes. To change the value, edit the following lines of code and replace 30 with your preference:
 +
 
 +
<pre>if ($age_minutes > 30) // if cache is more than 30 minutes old</pre>
 +
 
 +
<pre>if ($user_age > 30) // if cache is more than 30 minutes old</pre>
 +
 
 +
;You will need to do this in two places in the display_news.php page, once for logged in users and once for anonymous users.
 +
 
 +
* You can turn on a message that displays the last update time of the cache.  By default this message is turned off.  To enable the message uncomment the following lines of code in display_news.php (lines below shown without comments):
 +
 
 +
<pre>
 +
// ADD cache age message is more than 1 minute old -- off by default
 +
if ($user_age > 2) {
 +
    $boxtitle.= "<font size=\"-2\"><br>Last updated $user_age minutes ago</font>.";
 +
}
 +
 
 +
// ADD cache age message is more than 1 minute old -- off by default
 +
if ($age_minutes > 2) {
 +
    $boxtitle.= "<font size=\"-2\"><br>Last updated $age_minutes minutes ago</font>.";
 +
}
 +
</pre>
 +
 
 +
 
 +
= Changes =
 +
 
 +
* Fixed hard coded tables and added 'gl_' prefix to all code - 7/22/02
 +
* Created a MySQL based cache and removed the existing file cache - 6/1/2002
 +
* Changed the "expiree" events logic - 6/1/2002
 +
* Fixed backslashes with the stripslashes() - thanks Dirk!
 +
* Now uses RDF/RSS feeds...no more parsing ABCNews.com!
 +
* Fixed caching bug
 +
 
 +
;Version 1.4 (July 23, 2002)
 +
Fourth public production release
 +
 
 +
;Danny Ledger
 +
 
 +
 
 +
[[Category:Blocks]]

Latest revision as of 18:13, 12 May 2009

Introduction

The Headline News block is a Geeklog phpblock for displaying links to featured news stories made available from ANY RDF/RSS compatible content feed. Included in the source code is a list of many popular RDF/RSS feeds. These feeds are available for public use on Moreover: http://w.moreover.com/categories/category_list_xml.html.


Features

Headline News block features are as follows:

  • Displays links to stories for RDF/RSS compatible news feeds. The block utilizes the same code base as the standard Geeklog Portal block.
  • Consists of four views: default view, detailed view, category view, and administration view:
    • Default view is the main phpblock view (home page block). Registered users can customize the news provider. Anonymous users will receive the default provider set by the news administrator.
    • Detailed view is a secondary view where users can view specific feeds before setting their default provider.
    • Category view is a secondary view where users can view specific feeds sorted by category.
    • Administration view is where a user configures his/her default news feed and where the site news admin sets the default news feed. The news admin can also add, update, or delete RDF/RSS feeds.
  • Has built in MySQL caching.
  • Has a built in block timer for measuring the execution time of the block.


List of files with descriptions

FILE: DESCRIPTION:
/path/to/geeklog/public_html/news/display_news.php Core phpblock.
/path/to/geeklog/public_html/news/news_details.php View specific feeds before setting default provider.
/path/to/geeklog/public_html/news/top_news.php Top news feeds.
/path/to/geeklog/public_html/news/admin.php News administration page.


Instructions - New install

  1. Extract the code to /public_html.
    A new directory named "news" will be created for you.
  2. Run the SQL script: news-sql.sql
    The script will create one new table named gl_newsblock and make updates to gl_userprefs and gl_groups tables.
  3. Add the following to the /path/to/geeklog/system/lib-database.php
    --- CODE BEGINS ---
    $_TABLES['newsblock'] = $_DB_table_prefix . 'newsblock';
    --- CODE ENDS ---
  4. Add the phpblock: news.phpblock
    1. The first step is to add the contents of news.phpblock to lib-custom.php.
    2. The second step is to simply create the phpblock and reference the phpblock_getnews function.
  5. Set the default news provider for anonymous or guest users:
    1. First add your admin user to the "News Admin" group. Do this via the Geeklog user administration.
    2. Second, login as the admin user and click the "Edit" link on the news block. You will be presented with options for setting the global default news provider.
    3. Select the appropriate links to set the defaults.


Notes

  • If the block display looks off (bad alignment, incorrect content, ect). Delete the news_cache and set news_cache_expire = 1 for the suspect user (uid 1 = anonymous) in gl_userprefs. This will re-paint the block with updated content.
  • The block also has a built in timer. To enable the timer, uncomment the following lines in lib-custom.php:
//$_NEWS_TIMER = new timerobject();
//$_NEWS_TIMER->startTimer();      
AND uncomment the lines in display_news.php
//$boxtitle.= "<small><br>Created this block in <b>";
//$boxtitle.= $_NEWS_TIMER->stopTimer();
//$boxtitle.= "</b> seconds.</small>";
  • You can adjust the cache values by editing the display_news.php file. By default, cache is stored for 30 minutes. To change the value, edit the following lines of code and replace 30 with your preference:
if ($age_minutes > 30) // if cache is more than 30 minutes old
if ($user_age > 30) // if cache is more than 30 minutes old
You will need to do this in two places in the display_news.php page, once for logged in users and once for anonymous users.
  • You can turn on a message that displays the last update time of the cache. By default this message is turned off. To enable the message uncomment the following lines of code in display_news.php (lines below shown without comments):
// ADD cache age message is more than 1 minute old -- off by default
if ($user_age > 2) {	
    $boxtitle.= "<font size=\"-2\"><br>Last updated $user_age minutes ago</font>."; 
}
   
// ADD cache age message is more than 1 minute old -- off by default
if ($age_minutes > 2) {	
    $boxtitle.= "<font size=\"-2\"><br>Last updated $age_minutes minutes ago</font>.";
}


Changes

  • Fixed hard coded tables and added 'gl_' prefix to all code - 7/22/02
  • Created a MySQL based cache and removed the existing file cache - 6/1/2002
  • Changed the "expiree" events logic - 6/1/2002
  • Fixed backslashes with the stripslashes() - thanks Dirk!
  • Now uses RDF/RSS feeds...no more parsing ABCNews.com!
  • Fixed caching bug
Version 1.4 (July 23, 2002)

Fourth public production release

Danny Ledger