Only description of post in RSS

Discussions about the phpBB3 Forum. How to get the best from this powerful script.
Note that there is no official support for phpBB3 here, a place to share more than to ask for.

Moderator: Moderators

Only description of post in RSS

Postby PDD_20 » Thu Jul 03, 2008 6:01 pm

Hi, I have this mod RSS with URL SEO and i would like only show a description of post and not all post.

Can you help me?

Thanks

I give the code:

Code: Select all
<?php
/*
*
* @package phpBB3
* @version $Id: syndication.php,v 1.0 2006/11/27 22:29:16 angelside Exp $
* @copyright (c) Canver Software
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

// Begin configuration
$CFG['exclude_forums']    = '1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300';
$CFG['max_topics']       = '25';
// End configuration

// requests
$fid    = request_var('fid', '');
$count    = request_var('count', 0);
$chars    = request_var('chars', 200);
$type    = request_var('type', '');
$topics_only = request_var('t', '');

// If not set, set the output count to max_topics
$count = ( $count == 0 ) ? $CFG['max_topics'] : $count;

// maximum text char limit
if($chars<0 || $chars>500) $chars=500; //Maximum

// generate url
$board_url = generate_board_url();
$index_url = $board_url . '/index.' . $phpEx;
$viewtopic_url = $board_url . '/viewtopic.' . $phpEx;


// below three function barroved on "Full Syndication Suite 0.9.4a"

/**
* parse a message
*/
function parse_message($row, $bbcode_options, $bbcode_uid, $bbcode_bitfield)
{
   global $board_url;

   $row = html_entity_decode(generate_text_for_display($row, $bbcode_uid, $bbcode_bitfield, $bbcode_options));

   // smilies contain relative URL, we need it to be absolute
   return str_replace('<img src="./', '<img src="' . $board_url . '/', $row);
}

/**
* encode message for usage with RSS
*/
function rss_prepare_message(&$message)
{
   // embed message into CDATA tags in case it contains HTML tags or entities
   if (preg_match('/<[^>]+>|&#?[\w]+;/', $message))
   {
      // replace any ]]>
      $message = str_replace(']]>', ']]&gt;', $message);
      $message = '<![CDATA[' . $message . ']]>';
   }
}

/**
* create a date according to RFC 3339 or 822
*/
function format_date($timestamp)
{
   global $type;
   if ($type == 'atom')
   {
      // RFC 3339 for ATOM
      return date('Y-m-d\TH:i:s\Z', $timestamp);
   }
   else
   {
      // RFC 822 for RSS2
      return date('D, d M Y H:i:s O', $timestamp);
   }
}

$sql_where = '';

// only topic first post
if ($topics_only == 1)
{
   $sql_where = 'AND p.post_id = t.topic_first_post_id';
   $sql_from = 'FROM ' . POSTS_TABLE . ' as p, ' . FORUMS_TABLE . ' as f, ' . USERS_TABLE . ' as u, ' . TOPICS_TABLE . ' as t';
}
else
{
   //$sql_from = 'FROM ' . POSTS_TABLE . ' as p, ' . FORUMS_TABLE . ' as f, ' . USERS_TABLE . ' as u';
   $sql_where = 'AND p.post_id = t.topic_first_post_id';
   $sql_from = 'FROM ' . POSTS_TABLE . ' as p, ' . FORUMS_TABLE . ' as f, ' . USERS_TABLE . ' as u, ' . TOPICS_TABLE . ' as t';
}

// Exclude forums
if ($CFG['exclude_forums'])
{
   $exclude_forums = explode(',', $CFG['exclude_forums']);
   foreach ($exclude_forums as $i => $id)
   {
      if ($id > 0)
      {
         $sql_where .= ' AND p.forum_id != ' . trim($id);
      }
   }
}

if ($fid != '')
{
   $select_forums = explode(',', $fid);
   $sql_where .= ( sizeof($select_forums)>0 ) ? ' AND f.forum_id IN (' . $fid . ')' : '';
}

// SQL posts table
$sql = 'SELECT t.topic_title, t.topic_type, p.poster_id, p.post_subject, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.topic_id, p.forum_id, p.post_time, f.forum_name, f.forum_desc_options, u.username
      ' . $sql_from . '
      WHERE (u.user_id = p.poster_id)
      AND p.post_approved = 1
      AND (f.forum_id = p.forum_id)
      ' . $sql_where . '
      ORDER BY post_time DESC';
$result = $db->sql_query_limit($sql, $count);

while( ($row = $db->sql_fetchrow($result)) )
{

   if (!$auth->acl_get('f_list', $row['forum_id']))
   {
      // if the user does not have permissions to list this forum, skip everything until next branch
      continue;
   }

   ($type != 'atom') ? rss_prepare_message($row['post_text']) : '';
    // www.phpBB-SEO.com SEO TOOLKIT BEGIN
   if ( empty($phpbb_seo->seo_url['topic'][$row['topic_id']]) ) {
      if ($row['topic_type'] == POST_GLOBAL) {
         $phpbb_seo->seo_opt['topic_type'][$row['topic_id']] = POST_GLOBAL;
      }
      $phpbb_seo->seo_url['topic'][$row['topic_id']] = $phpbb_seo->format_url(censor_text($row['topic_title']));
   }
   if ( empty($phpbb_seo->seo_url['forum'][$row['forum_id']]) ) {
      $phpbb_seo->seo_url['forum'][$row['forum_id']] = $phpbb_seo->set_url($row['forum_name'],$topic_data['forum_id'], $phpbb_seo->seo_static['forum']);
   }
   // www.phpBB-SEO.com SEO TOOLKIT END

   $template->assign_block_vars('item', array(
      'AUTHOR'      => $row['username'],
      'TIME'         => format_date($row['post_time']),
      'LINK'         => append_sid("$board_url/viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
      'IDENTIFIER'   => append_sid("$board_url/viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
      'TITLE'         => $row['post_subject'],
      'TEXT'         => parse_message($row['post_text'], $row['forum_desc_options'], $row['bbcode_uid'], $row['bbcode_bitfield']),      
      )
   );   
}

if ($type == 'atom')
{
   $template->assign_var('FEED_LINK', $board_url);
   $content_type = 'application/atom+xml';
   $tpl = 'atom';
}
else
{
   $content_type = 'application/rss+xml';
   $tpl = 'rss2';
}

$template->set_filenames(array(
   'body' => 'syndication_' . $tpl . '.xml')
);

// get time, use current time
$last_build_date = mktime();

$template->assign_vars(array(
   'HEADER'      => '<?xml version="1.0" encoding="UTF-8"?>' . "\n", // workaround for remove_php_tags() removing this line from the template
   'TITLE'         => strip_tags($config['sitename']),
   'DESCRIPTION'   => strip_tags($config['site_desc']),
   'LINK'         => $board_url,
   'LAST_BUILD'   => format_date($last_build_date)
   )
);

// gzip compression
if ($config['gzip_compress'])
{
   if (@extension_loaded('zlib') && !headers_sent())
   {
      ob_start('ob_gzhandler');
   }
}

// start output
header ('Content-Type: ' . $content_type . '; charset=UTF-8');
$template->display('body');
exit;

?>
PDD_20
PR1
PR1
 
Posts: 136
Joined: Fri May 23, 2008 4:42 pm
Location: Spain

Advertisement

Postby SeO » Fri Jul 04, 2008 9:59 am

GYM sitemaps 2.0 is too close to be released to work on any other mod, believe me, you won't regret it ;)
SeO
Admin
Admin
 
Posts: 6334
Joined: Wed Mar 15, 2006 9:41 pm

Postby PDD_20 » Fri Jul 04, 2008 10:40 am

When have we GYM Sitemaps for phpbb3?

Thanks
PDD_20
PR1
PR1
 
Posts: 136
Joined: Fri May 23, 2008 4:42 pm
Location: Spain

Postby HB » Fri Jul 04, 2008 1:23 pm

I could tell you, but then I would have to kill you. :lol:
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1509
Joined: Mon Oct 16, 2006 2:25 am

Postby PDD_20 » Fri Jul 04, 2008 1:25 pm

HB wrote:I would tell you, but then I would have to kill you. :lol:


Ok :D

I wait for it, I know GYM Sitemap is good because phpbb SEO gruop is the best :D

Thanks.
PDD_20
PR1
PR1
 
Posts: 136
Joined: Fri May 23, 2008 4:42 pm
Location: Spain

Postby HB » Fri Jul 04, 2008 2:03 pm

I've been beta testing it for a couple months and it is very slick. That said, IMHO, the RSS feed is the more interesting feature (i.e., Google is very good at figuring out URLs without a sitemap).
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1509
Joined: Mon Oct 16, 2006 2:25 am

Postby PDD_20 » Fri Jul 04, 2008 3:35 pm

Can you help me with my problem with my actual RSS? :S

I need it soon.

Thanks
PDD_20
PR1
PR1
 
Posts: 136
Joined: Fri May 23, 2008 4:42 pm
Location: Spain

Postby HB » Fri Jul 04, 2008 4:25 pm

Sorry, no. Given that GYM's RSS has all the features you could possibly desire and then some, I see no point in investing effort in the code above. I've been saying for two weeks that the GYM RSS code is good enough for a beta, but it's up to dcz. :wink:
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1509
Joined: Mon Oct 16, 2006 2:25 am


Return to phpBB Forum

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 99 guests