News: September 21st, 2019, The Tinyportal team is pleased to announce the release of ~~ TinyPortal 1.6.4! GET IT NOW!!!

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

October 21, 2019, 11:20:00 AM

Login with username, password and session length

Recent

Members
  • Total Members: 3756
  • Latest: Ocean
Stats
  • Total Posts: 189111
  • Total Topics: 20766
  • Online Today: 145
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 1
Guests: 43
Total: 44

Author Topic: Twitter feed in a block  (Read 7751 times)

0 Members and 1 Guest are viewing this topic.

Offline bayonetbrant

  • Newbie
  • *
  • Posts: 3
Twitter feed in a block
« on: March 29, 2016, 10:25:09 AM »
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

Offline lurkalot

  • Administrator
  • *
  • Posts: 6298
    • Camera Craniums
Re: Twitter feed in a block
« Reply #1 on: March 29, 2016, 11:13:20 AM »
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? 

Offline bayonetbrant

  • Newbie
  • *
  • Posts: 3
Re: Twitter feed in a block
« Reply #2 on: March 29, 2016, 12:06:07 PM »
Just using the standard RSS block

Offline lurkalot

  • Administrator
  • *
  • Posts: 6298
    • Camera Craniums
Re: Twitter feed in a block
« Reply #3 on: March 29, 2016, 12:40:53 PM »
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.

Offline illori

  • Administrator
  • *
  • Posts: 2051
Re: Twitter feed in a block
« Reply #4 on: March 29, 2016, 02:55:07 PM »
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.

Offline lurkalot

  • Administrator
  • *
  • Posts: 6298
    • Camera Craniums
Re: Twitter feed in a block
« Reply #5 on: March 29, 2016, 04:15:37 PM »
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.

Offline illori

  • Administrator
  • *
  • Posts: 2051
Re: Twitter feed in a block
« Reply #6 on: March 29, 2016, 04:33:54 PM »
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.

Offline illori

  • Administrator
  • *
  • Posts: 2051
Re: Twitter feed in a block
« Reply #7 on: March 29, 2016, 05:56:50 PM »
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>';

Offline bayonetbrant

  • Newbie
  • *
  • Posts: 3
Re: Twitter feed in a block
« Reply #8 on: March 29, 2016, 09:03:32 PM »
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!

Offline VladTepes

  • Jr. Member
  • **
  • Posts: 78
Re: Twitter feed in a block
« Reply #9 on: March 25, 2017, 06:49:21 PM »
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?