RSS Feed Title & Summary Cropping
Permalink 1 user found helpful
I have managed to get my Facebook Status updates RSS feed on a site I'm working on:http://www.davidcunniffe.com/test3/index.php?cID=69...
The title and the summary are currently displaying as the same thing.
What I want to do is edit the "view.php" file (in the rss_displayer folder) so each RSS item title is cropped after a certain number of words and the summary text then begins from where the title has stopped.
Is this possible? Thanks
The title and the summary are currently displaying as the same thing.
What I want to do is edit the "view.php" file (in the rss_displayer folder) so each RSS item title is cropped after a certain number of words and the summary text then begins from where the title has stopped.
Is this possible? Thanks
Wow, I had no idea there was a way to get Facebook status updates out of Facebook!
Okay, taking a peak at view.php for the RSS Displayer block, here's what I'm seeing:
You would just want to wrap whichever portion you wish to create a substring for. For example, if you wanted to limit the title, you would replace "$item->get_title();" with "substr ($item->get_title(), 0, 100);". In the same way, you could encapsulate "$textHelper->shortText( strip_tags($item->get_description())" to shorten the summary.
Does that help?
If you don't know already, you can do this as a custom template so that you don't have to edit the core block. Just copy view.php from the block and save it as /blocks/rss_displayer/templates/facebook_template.php or whatever you want to call it. When you put it on your server, you will be able to edit a page, click on an RSS Displayer block, select "Custom Template" off the list of options then select your template, and it will replace the default view.php code with your custom code.
Okay, taking a peak at view.php for the RSS Displayer block, here's what I'm seeing:
<div class="rssItem"> <div class="rssItemTitle"> <a href="<?= $item->get_permalink(); ?>" <? if($rssObj->launchInNewWindow) echo 'target="_blank"' ?> > <?= $item->get_title(); ?> </a> </div> <div class="rssItemDate"><?= $item->get_date($dateFormat); ?></div> <div class="rssItemSummary"> <? if( $rssObj->showSummary ){ echo $textHelper->shortText( strip_tags($item->get_description()) ); } ?> </div> </div>
You would just want to wrap whichever portion you wish to create a substring for. For example, if you wanted to limit the title, you would replace "$item->get_title();" with "substr ($item->get_title(), 0, 100);". In the same way, you could encapsulate "$textHelper->shortText( strip_tags($item->get_description())" to shorten the summary.
Does that help?
If you don't know already, you can do this as a custom template so that you don't have to edit the core block. Just copy view.php from the block and save it as /blocks/rss_displayer/templates/facebook_template.php or whatever you want to call it. When you put it on your server, you will be able to edit a page, click on an RSS Displayer block, select "Custom Template" off the list of options then select your template, and it will replace the default view.php code with your custom code.
I will try this tomorrow. Thanks.
To get your Facebook status RSS feed, just search in Facebook for 'Status Export'. It's an app you add to your page which gives you the code you need to add to the RSS Displayer.
To get your Facebook status RSS feed, just search in Facebook for 'Status Export'. It's an app you add to your page which gives you the code you need to add to the RSS Displayer.
OK. Got the title to shorten to 40 characters, but now I am trying to get the summary to start on the 41st character:
This is the code I'm using:
echo substr ($textHelper->shortText( strip_tags($item->get_description()), -40, 0) );
but I get this error:
Warning: Wrong parameter count for substr() in /home/davidcun/public_html/test3/concrete/blocks/rss_displayer/view.php on line 36
Also, is it possible when creating a template to have a different CSS style for it?
This is the code I'm using:
echo substr ($textHelper->shortText( strip_tags($item->get_description()), -40, 0) );
but I get this error:
Warning: Wrong parameter count for substr() in /home/davidcun/public_html/test3/concrete/blocks/rss_displayer/view.php on line 36
Also, is it possible when creating a template to have a different CSS style for it?
Can anyone help me with this? Thanks
Anybody?
I have been playing around with this and found that this works
it effectively truncates the summary, but now I need to add in the ellipses to show that there is more to be read.
echo $textHelper->shortText( strip_tags(substr ($item->get_description(),0,100)) );
it effectively truncates the summary, but now I need to add in the ellipses to show that there is more to be read.
ok that was quick:
This will limit the summary to 180 characters and add the ellipses to the end.
echo $textHelper->shortText( strip_tags(substr ($item->get_description(),0,180)) ."...");
This will limit the summary to 180 characters and add the ellipses to the end.
OK. I found something called substr(), but I don't know where to put it in my code.
Here is an example.
<?php
$rest = substr("abcdef", 1); // returns "bcdef"
$rest = substr("abcdef", 1, 3); // returns "bcd"
$rest = substr("abcdef", 0, 4); // returns "abcd"
$rest = substr("abcdef", 0, 8); // returns "abcdef"
// Accessing via curly braces is another option
$string = 'abcdef';
echo $string{0}; // returns a
echo $string{3}; // returns d
?>