Customizing the Atom Feed entry titles?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
cero2k
Registered User
Posts: 3
Joined: Sun Aug 01, 2010 6:36 am

Customizing the Atom Feed entry titles?

Post by cero2k »

I've been trying to figure out the best way to format out the titles of the Atom Feed entries. Regardless of the settings, i always get [Forum Title] • [Topic Title]. I particularly want to remove the Forum Title and possibly add some extra info like author and date after the topic title.

What file should I be looking at in order to make this modifications, I've been looking around in feed.php but haven't figured out anything yet.

thanks in advance.
User avatar
P_I
Community Team Member
Community Team Member
Posts: 1896
Joined: Tue Mar 01, 2011 8:35 pm
Location: Western Canada 🇨🇦
Contact:

Re: Improving the Atom Feed entry titles?

Post by P_I »

Bringing this topic back to life because I've got the same question. I've read through FAQ: phpBB ATOM feeds and played with the various ACP->Feed settings.

I've also been searching through the feed.php code. It looks pretty straight forward, but I'm mystified how the row['title'] element in line 220

Code: Select all

echo '<title type="html"><![CDATA[' . $row['title'] . ']]></title>' . "\n\n";
is built.

It seems to happen around line 103

Code: Select all

    $title = (isset($row[$feed->get('title')]) && $row[$feed->get('title')] !== '') ? $row[$feed->get('title')] : ((isset($row[$feed->get('title2')])) ? $row[$feed->get('title2')] : '');

    $published = ($feed->get('published') !== NULL) ? (int) $row[$feed->get('published')] : 0;
    $updated = ($feed->get('updated') !== NULL) ? (int) $row[$feed->get('updated')] : 0;

    $display_attachments = ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && isset($row['post_attachment']) && $row['post_attachment']) ? true : false;

    $item_row = array(
        'author'        => ($feed->get('creator') !== NULL) ? $row[$feed->get('creator')] : '',
        'published'     => ($published > 0) ? $phpbb_feed_helper->format_date($published) : '',
        'updated'       => ($updated > 0) ? $phpbb_feed_helper->format_date($updated) : '',
        'link'          => '',
        'title'         => censor_text($title),
        'category'      => ($config['feed_item_statistics'] && !empty($row['forum_id'])) ? $board_url . '/viewforum.' . $phpEx . '?f=' . $row['forum_id'] : '',
        'category_name' => ($config['feed_item_statistics'] && isset($row['forum_name'])) ? $row['forum_name'] : '',
        'description'   => censor_text($phpbb_feed_helper->generate_content($row[$feed->get('text')], $row[$feed->get('bbcode_uid')], $row[$feed->get('bitfield')], $options, $row['forum_id'], ($display_attachments ? $feed->get_attachments($row['post_id']) : array()))),
        'statistics'    => '',
    );

    // Adjust items, fill link, etc.
    $feed->adjust_item($item_row, $row);

    $item_vars[] = $item_row;
Does anyone know how the forum name is prefixed to the topic title? and more importantly how it could be removed?
Last edited by P_I on Thu Dec 08, 2016 12:31 pm, edited 1 time in total.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
User avatar
Volksdevil
Registered User
Posts: 2415
Joined: Sun Oct 03, 2010 2:03 pm
Location: Lancashire, UK
Name: Neil
Contact:

Re: Customizing the Atom Feed entry titles?

Post by Volksdevil »

Also interested in this. That damn &bull; annoys me!
My phpBB Extensions
Finally found great Website Hosting from :arrow: KUALO!
Do NOT use 123-reg.co.uk - Incapable of running phpBB!
:ugeek: TekNeil - Streamer on Twitch | My Volkswagen Corrado G60
User avatar
P_I
Community Team Member
Community Team Member
Posts: 1896
Joined: Tue Mar 01, 2011 8:35 pm
Location: Western Canada 🇨🇦
Contact:

Re: Customizing the Atom Feed entry titles?

Post by P_I »

Found it. It gets done in the adjust_item() method. The implementations are found in the phpbb/feeds/*.php files.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
User avatar
P_I
Community Team Member
Community Team Member
Posts: 1896
Joined: Tue Mar 01, 2011 8:35 pm
Location: Western Canada 🇨🇦
Contact:

Re: Improving the Atom Feed entry titles?

Post by P_I »

cero2k wrote:Regardless of the settings, i always get [Forum Title] • [Topic Title]. I particularly want to remove the Forum Title
My solution to make feed.php?mode=topics_active look more like search.php?search_id=active_topics was to make the following changes:
  • in phpbb/feed/topics_active.php suppress displaying the forum name in the Atom:title element

    Code: Select all

    129c129
    <               $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title'];
    ---
    > //            $item_row['title'] = (isset($row['forum_name']) && $row['forum_name'] !== '') ? $row['forum_name'] . ' ' . $this->separator . ' ' . $item_row['title'] : $item_row['title'];
    
  • in phpbb/feed/base.php change the statistics separator

    Code: Select all

    <       var $separator_stats = "\xE2\x80\x94"; // &mdash;
    ---
    >       var $separator_stats = "&raquo"; // match search.php?search_id=active_topics;
  • in phpbb/feed/topic_base.php display forum name link, remove replies and views counts

    Code: Select all

    50,51c50,52
    <                               . ' ' . $this->separator_stats . ' ' . $this->user->lang['REPLIES'] . ' ' . ($this->content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1)
    <                               . ' ' . $this->separator_stats . ' ' . $this->user->lang['VIEWS'] . ' ' . $row['topic_views'];
    ---
    >                 . ' ' . $this->separator_stats . ' ' . $this->user->lang['POSTED_IN_FORUM'] . ' ' . '<a href="' . $this->helper->append_sid('viewforum.' . $this->phpEx, 'f=' . $row['forum_id']) . '">' . $row['forum_name'] . '</a>';
    > //                            . ' ' . $this->separator_stats . ' ' . $this->user->lang['REPLIES'] . ' ' . ($this->content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1)
    > //                            . ' ' . $this->separator_stats . ' ' . $this->user->lang['VIEWS'] . ' ' . $row['topic_views'];
    
If you just want to change the &bull character between forum title and topic title per the following query:
Volksdevil wrote:Also interested in this. That damn &bull; annoys me!
Then look in phpbb/feed/base.php for

Code: Select all

    /**
    * Separator for title elements to separate items (for example forum / topic)
    */
    var $separator = "\xE2\x80\xA2"; // &bull;
Last edited by P_I on Thu Dec 08, 2016 12:30 pm, edited 1 time in total.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
Lady_G
Registered User
Posts: 268
Joined: Fri Jun 08, 2012 12:38 pm
Location: US

Re: Customizing the Atom Feed entry titles?

Post by Lady_G »

I am having some difficulty to follow your code changes for phpbb/feed/topic_base.php, which is a diff file output. There are 3 locations affected, but I can't find the exact code locations using a "Find" in my text editor.

Could you please revise your post to use a step-by-step instruction similar to the phpBB instructions for source code modifications?

I believe you are missing a trailing semicolon ';' from your suggested replacement separator character. for &raquo. The representation should instead be as &raquo;. (Ref: Character entity references in HTML 4)

Instead, may I suggest to use the same separator character used in the prosilver navbar header, '‹', coded as &#8249; or &lsaquo;? The style would be consistent with prosilver.

In phpbb/feed/base.php find:

Code: Select all

var $separator = "\xE2\x80\xA2"; // &bull;
Replace with:

Code: Select all

var $separator = "&lsaquo;"; // &lsaquo;
User avatar
P_I
Community Team Member
Community Team Member
Posts: 1896
Joined: Tue Mar 01, 2011 8:35 pm
Location: Western Canada 🇨🇦
Contact:

Re: Improving the Atom Feed entry titles?

Post by P_I »

Lady_G wrote:I am having some difficulty to follow your code changes
Fair enough. I've been trying out various changes/concepts so I'll give you my current version, which is slightly different than the previously posted change. In phpbb/feed/topic_base.php, on line 48 find:

Code: Select all

            $item_row['statistics'] = $this->user->lang['POSTED'] . ' ' . $this->user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row)
                . ' ' . $this->separator_stats . ' ' . $this->user->format_date($row[$this->get('published')])
add:

Code: Select all

                . ' ' . $this->separator_stats . ' ' . $this->user->lang['POSTED_IN_FORUM'] . ' ' . '<a href="' . $this->helper->append_sid('viewforum.' . $this->phpEx, 'f=' . $row['forum_id']) . '">' . $row['forum_name'] . '</a>'
If you want to remove the Replies and Views items so that it looks more like View active topics, then comment out the following two lines.
Lady_G wrote:I believe you are missing a trailing semicolon ';' from your suggested replacement separator character. for &raquo.
Lady_G wrote: Thanks. Although IE renders it properly without so I didn't notice the missing trailing semicolon.
Instead, may I suggest to use the same separator character used in the prosilver navbar header, '‹', coded as &#8249; or &lsaquo;? The style would be consistent with prosilver.
My goal was consistency with the format of search.php?search_id=active_topics
phpBB - active topics.PNG
Last edited by P_I on Thu Dec 08, 2016 12:30 pm, edited 1 time in total.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
User avatar
P_I
Community Team Member
Community Team Member
Posts: 1896
Joined: Tue Mar 01, 2011 8:35 pm
Location: Western Canada 🇨🇦
Contact:

Re: Improving the Atom Feed entry titles?

Post by P_I »

Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
wods
Registered User
Posts: 6
Joined: Tue Feb 07, 2017 4:07 pm

Re: Customizing the Atom Feed entry titles?

Post by wods »

it`s possibole add css?
User avatar
P_I
Community Team Member
Community Team Member
Posts: 1896
Joined: Tue Mar 01, 2011 8:35 pm
Location: Western Canada 🇨🇦
Contact:

Re: Customizing the Atom Feed entry titles?

Post by P_I »

Not sure I understand the question. Add CSS to what? The feed is governed by RFC 4287 - The Atom Syndication Format.
Normal people… believe that if it ain’t broke, don’t fix it. Engineers believe that if it ain’t broke, it doesn’t have enough features yet. – Scott Adams
wods
Registered User
Posts: 6
Joined: Tue Feb 07, 2017 4:07 pm

Re: Customizing the Atom Feed entry titles?

Post by wods »

i want to add css here
http://wods.altervista.org/feed.php

Code: Select all

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video  {margin: 0; padding: 0; border: 0; transition:all .2s ease-in}
body {max-width:220px; white-space: nowrap !important; 
  overflow:hidden !important; text-overflow:ellipsis !important;
  background: none; 
  font: 76%/1.6em Verdana, Tahoma, Arial, Sans-serif; color: #FFF; text-shadow: -1px -1px 0 #000}
a  {white-space: nowrap !important; overflow:hidden !important; text-overflow:ellipsis !important;
  width:auto;line-height: 13px;display:inline-block;text-decoration: none; border:none!important; 
  padding: 1px 8px 2px 8px!important; font-weight: 700; font-size: 11px; color: #202020!important; 
  text-shadow: 1px 1px 0 #DDD!important; background: #A6A6A6!important; border-radius: 7px; 
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5), inset 0 1px rgba(255, 255,  255, .3), inset 0 10px rgba(255, 255, 255, .2), inset 0 10px 20px  rgba(255, 255, 255, .25), inset 0 -15px 30px rgba(0, 0, 0, .3), 1px 1px 0  #303030, inset 1px 1px 0 #FFF!important}
a:hover {color: #FFF!important; text-shadow: 0px 0px 3px #000,0px 0px 3px #000!important}
img {height:0;opacity:0}
#feedHeaderContainer, h2, hr, #feedTitleLink, input {display:none}
div.feedEntryContent {line-height:0px;font-size:0;height:0}
.entry{background-image: url(wods.altervista.org/styles/prosilver/theme/immagini/sfondi/gsdsdgsome.png);
  margin-bottom:5px;padding:5px;height:48px!important;border-radius:10px!important;box-shadow:  -1px -1px 1px #000, 1px 1px 1px #C17643, inset 1px 1px 10px #050505}
.feedEntryContent a, h3 div{font-size:11px}
.feedEntryContent a:before{content: 'Inviato da: '}
h3{line-height:13px}
.feedEntryContent a {margin-top:2px}
Post Reply

Return to “Extension Writers Discussion”