masterdxb / sweetcron

Automatically exported from code.google.com/p/sweetcron
0 stars 0 forks source link

Feature Request: Customize twitter output to not display certain tweets. #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Say you enter a twitter and twitpic account, they update at the same time
and produce pretty much the same content, because twitpic automatically
updates twitter.

It would be nice if we could make the twitter plugin not display tweets
that have "from twitpic" in them as it looks redundant see here:

http://blissofbeing.com/sweetcron/

We could fix this by making the twitter plugin more customizable, like not
including the twitpic tweets, it would also be great if we could exclude
@replies also.

Original issue reported on code.google.com by waynesl...@gmail.com on 28 Aug 2008 at 8:16

GoogleCodeExporter commented 8 years ago
You should be able to filter this out in the _activity_feed.php file in your 
theme.
Use get_title() to get the twitter text, and maybe toss in get_feed_domain().  
Some
basic regex on the results of those will allow you to filter out whatever you 
want.

Original comment by pant...@gmail.com on 28 Aug 2008 at 9:37

GoogleCodeExporter commented 8 years ago
Suppose I want to filter out posts on Twitter that came Twitpic. I would 
probably 
try to filter on the hyperlink in the Twitter post and use the 
get_title()object.

This is the default filter for twitter in the activity_feed.php:
            <!-- this item came from twitter.com -->
            <?php elseif ($item->get_feed_domain() == 'twitter.com'): ?>
            <li class="activity_item regular<?php if ($i % 3 == 0):?> last<?php 
endif;?>">
            <div class="activity_list_inner">
            <span class="type_label regular"></span>
                <div class="regular_container">
                    <cite class="avatar"><img src="<?php echo $this->config->item
('theme_folder')?>images/me.jpg" alt="" /></cite>
                    <div class="speech_tail"></div>
                    <div class="speech_bubble">
                    <?=$item->get_title()?>
                    </div>                
                </div>

How would I add a filter on the hyperlink in the item_title so that posts with 
a 
Twitpic url are dropped?

Thanks!
Stefan

Original comment by ste...@stranger.nl on 30 Aug 2008 at 7:59

GoogleCodeExporter commented 8 years ago
This is probably not the most elegant place to make this patch, rather look in 
the 

application/plugins/twitter_com.php script

although there's no way to cancel the item, you could return null from the
pre_display function for items not to display, and add a
<?php if(is_null($item)) continue; ?>
in _activity_feed.php

Original comment by willscott on 31 Aug 2008 at 1:28

GoogleCodeExporter commented 8 years ago
if i don't want any of my '@' replies to go on the feed then?

Original comment by amm...@gmail.com on 31 Aug 2008 at 12:06

GoogleCodeExporter commented 8 years ago
Hi Will,

I added the next lines to the twitter plugin:

function pre_display($item)
    {
        //Filter posts from Twitpic
             $url = 'http://twitpic.com';
        if (strstr($item->get_title(),$url)){
            //echo "Found $url $item";
            $return = null;
        } else {
            echo "Not Found";
        return $item;
        }
    }

And added 
<?php if(is_null($item)) continue; ?>
in _activity_feed.php

But I still get the next error:
Fatal error: Call to undefined method stdClass::get_feed_domain() 
in 
/home/stranger/domains/stranger.nl/public_html/system/application/views/themes/b
ox
y_but_good/_activity_feed.php on line 9

Any ideas?

Regards,
Stefan

Original comment by ste...@stranger.nl on 31 Aug 2008 at 12:12

GoogleCodeExporter commented 8 years ago
Stefan:  the 
<?php if(is_null($item)) continue; ?>

needs to be around line 4 or 5, before any of the conditions.
You are probably checking for null at the twitter section, but it checks for 
instance
if the item came is a blog post before that, and fails.
Move the is_null line to right after the 
        <?php if ($items): $i = 1; foreach ($items as $item): ?>

Original comment by willscott on 1 Sep 2008 at 1:32