TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 16, 2024, 05:19:59 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,158
  • Total Topics: 21,219
  • Online today: 92
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 99
  • Total: 99

Twitter feed in a block

Started by bayonetbrant, March 29, 2016, 05:25:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bayonetbrant

Hi guys,

I'm using TinyPortal to enhance the forum page at grogheads dot com slash forums

We have a front page for the site that handles most of the articles we publish, so I don't need a ton of article management from TinyPortal, but I do want more on our forum screen (where most of our audience hangs out all day)

So far, I have an RSS feed that notifies them of new articles on the main page of the site, and a "recent posts" box that, honestly, is kind of just taking up space.

I thought it might be cool to include a Twitter feed block since our Twitter feed includes info from other companies/sites, not just our own.
I've been looking around and back before Twitter changed their APIs, you could just create an RSS feed of your Twitter feed and put it into an RSS box, but that's been broken for a few years now.

I can't find any other good answer on how (or if) you can put a Twitter feed in a block on TinyPortal.

Help?

Thanks!
Brant

lurkalot

Hi Brant, and welcome to TP support.

What script are you using to display your other RSS feeds in your right panel? or are you just using the built in Tinyportal RSS feed block? 

bayonetbrant

Just using the standard RSS block

lurkalot

Thanks.

OK, one option to generate a twitter feed very quick and easy. https://twitrss.me/

The RSS block itself worries me, because the built in block doesn't have any control over the amount of feed items shown in the block, so could, and probably will result in a very odd looking block.  ;)

Next step would be to find a suitable script to display and control your RSS feed nicely in a block.  I use one that I found on one of my sites, but to be honest I just tried it in a side panel and it doesn't look too pretty. I haven't found another one atm.

illori

thanks to http://pastebin.com/UCu16024 and http://stackoverflow.com/questions/8280986/rss-feed-generating-the-image

it is not too hard to code in a max number of entries to show...

in Sources/TPSubs.php

Code (find) Select

function endElement($parser, $tagName)
{
// This function is used when an end-tag is encountered.
global $context, $smcFunc, $insideitem, $tag, $title, $description, $link, $tpimage, $curl, $content_encoded, $pubdate, $content, $created;


Code (replace) Select

function endElement($parser, $tagName)
{
// This function is used when an end-tag is encountered.
global $context, $smcFunc, $insideitem, $tag, $title, $description, $link, $tpimage, $curl, $content_encoded, $pubdate, $content, $created, $numShown;



Code (find) Select
// RSS/RDF feeds
if ($tagName == "ITEM")
{


Code (add after) Select

if ($numShown >= 3)
{
            return;
        }

        $numShown ++;


Code (find) Select
// ATOM feeds
elseif ($tagName == "ENTRY")
{


Code (add after) Select
if ($numShown >= 3)
{
            return;
        }

        $numShown ++;


now you can only show 3 entries from that RSS feed. i think with some effort we can try to add this as a setting for the RSS module, right now i dont have time to look into that though.

lurkalot

Illori, being able to add a bit of control to the RSS block would be a long awaited and very welcome feature.  I'm sure you've seen this mentioned a few times, mainly by me lol..

I'm using a similar but smaller script on my site for displaying RSS feeds in a PHP block.

One here, set to 20 items, http://guitaristguild.com/index.php?page=ebay.com-feed and one in the middle of my home page, set to 6 items. They don't look too pretty though.

I can't for the life of me find the site I got it from though, my bookmark has gone AWOL.  I will try and find it though.

illori

the above code lets you do that. i have some other that will let you modify the number in the admin panel i will post when i get a chance.

illori

based on the code posted above...

in Sources/TPSubs.php

Code (find) Select

function endElement($parser, $tagName)
{
// This function is used when an end-tag is encountered.
global $context, $smcFunc, $insideitem, $tag, $title, $description, $link, $tpimage, $curl, $content_encoded, $pubdate, $content, $created;


Code (replace) Select

function endElement($parser, $tagName)
{
// This function is used when an end-tag is encountered.
global $context, $smcFunc, $insideitem, $tag, $title, $description, $link, $tpimage, $curl, $content_encoded, $pubdate, $content, $created, $numShown;



Code (find) Select
// RSS/RDF feeds
if ($tagName == "ITEM")
{


Code (add after) Select

if ($numShown >= $context['TPortal']['rssnumber'])
{
            return;
        }

        $numShown ++;


Code (find) Select
// ATOM feeds
elseif ($tagName == "ENTRY")
{


Code (add after) Select
if ($numShown >= $context['TPortal']['rssnumber'])
{
            return;
        }

        $numShown ++;


TPortalAdmin.template.php i know it should be a text string but good enough for here
Code (find) Select
<tr class="windowbg2"><td class="left">' . $txt['tp-rssblock-maxwidth'].'</td><td class="right">

Code (replace) Select
<tr class="windowbg2"><td class="left">Max Items</td><td class="right">


TPortal.php

Code (find) Select
$context['TPortal']['rsswidth'] = isset($block['var3']) ? $block['var3'] : '';

Code (replace) Select
$context['TPortal']['rssnumber'] = isset($block['var3']) ? $block['var3'] : '';

TPsubs.template.php

Code (find) Select
echo '<div style="padding: 5px; ' , !empty($context['TPortal']['rsswidth']) ? 'max-width: ' . $context['TPortal']['rsswidth'] .';' : '' , '"

Code (replace) Select
echo '<div style="padding: 5px; width: 150px;" class="middletext">' , TPparseRSS('', $context['TPortal']['rss_utf8']) , '</div>';

bayonetbrant

I've got an RSS feed working based on the twitrss dot me feed mentioned earlier.

it would be nice to be able to limit the number of entries in a more programatic fashion than having to insert custom code, but so far it's doing what I need for the page it's on.

Thanks!

VladTepes

So to get an RSS feed working well for me.. do I use the RSS feed block and make code changes as per both of Illori's posts above?
Or is there some other / easier way?  Maybe an RSS script from somewhere just run in a script block? If so, what's a good script to use?