Skip to:
Content
Pages
Categories
Search
Top
Bottom

New Plugin: Activity Stream #Hashtags

  • Same fundamentals as the atmention auto-link – this will catch a #hashtags and convert them into a link. The link will load the same activity-loop index template but modifies the querystring to include the search_term args. (so other activity ajax filtering works in conjunction )

    Warning – links are converted prior to database saving – so if you wanted to disable the plugin the links will live on. (and probably to a 404). Sorry – this was the easy and best way to utilize the search_terms and built-in has_activities loop – since the sql within the ::get uses %%term%% – the ending delimiter is the closing a href tag. (exactly how mentions work in the activity-loop). Think I wrote 3 lines of code and just reused the rest – very simple.

    You can include blog excerpts for posts and comments which are saved to the activity stream but you’ll need to add the following filters (functions or bp-custom will do)

    `
    add_filter( ‘bp_blogs_activity_new_post_content’, ‘bp_activity_hashtags_filter’ );
    add_filter( ‘bp_blogs_activity_new_comment_content’, ‘bp_activity_hashtags_filter’ );
    `

    You may also change up the slug, just define BP_ACTIVITY_HASHTAGS_SLUG (default is: tag – so mydomain/bp-activity-slug/hashtags-slug/hashtag (remember the above statement about pre_ db content so it may break older links)

    This the pattern that hits
    /[#]([_0-9a-zA-Z-]+)/ (then double checks again for (^|s|b)#myactualhashtag )

Viewing 20 replies - 26 through 45 (of 45 total)
  • Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    @anaxent that is the permalink for the activity record – i just rewrote the order of the links via the filter bp_insert_activity_meta (have a look at bp-activity-templatetags.php on how that function is done)

    Avatar of Nm
    nm
    Participant

    @nahummadrid

    don’t quite understand…for now I need to stop, step back and see what I can do to remove whatever is causing this. I just tried to switch my themes and then back and lost some more settings. what do you suggest as steps to remove the plugin and any tags.

    Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    Well the cause is the behavior of the plugin and the ajax querystring filters/cookies. It just retains what you’re currently viewing, so you navigate back up to the normal activity page – you’ll see the normal results. Maybe I’m not understanding your problem correctly – this plugin won’t interfere with any settings

    Avatar of anaxent
    anaxent
    Member

    @anaxent

    @rich! @ etiviti and would the code be inserted into the bp-custom.php?

    Avatar of Nm
    nm
    Participant

    @nahummadrid

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘bp_activity_hashtags_filter’ was given in /home/…/wp-includes/plugin.php on line 166

    *edit, that’s right. but i still couldn’t figure out why it was setting that test page with the hastag in it, as my home page. i finally just reset plugins and was able to get the homepage reading settings back to normal.
    *edit, seems there was a conflict with a Redirect plugin. it was only I after testing #hashtag in a page that it happenend. when i was testing # in posts it seemed to be fine.

    Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    probably since you added those extra filters to the blogs posts and comments – and is looking for the deactivated functions.

    Avatar of Anton
    Anton
    Participant

    @antonrsa

    Anyway that hashtags can be built into the search form so that when you search, you can choose to search for hashtags on the dropdown?

    Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    looking at that now – the core bp_search_form_type_select function needs an action to add something to the list

    Avatar of Anton
    Anton
    Participant

    @antonrsa

    Started a forum topic in this group: http://buddypress.org/community/groups/buddypress-activity-stream-hashtags/forum/topic/rss-request/

    Can RSS feeds be included on the hashtag page?

    Avatar of Anton
    Anton
    Participant

    @antonrsa

    @nuprn1 for the hashtags page, how can I include a meta title for those pages? It seems they are missing.

    Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    i’ll add in a simple function to display the hashtag in the title – though i won’t be able to get to it until next week at the earliest (i’ll look into rss stuff then as well)

    Avatar of Anton
    Anton
    Participant

    @antonrsa

    Thanks @nuprn1

    Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    did a little work on it late last night

    http://etivite.com/activity/tag/hashtags
    http://etivite.com/activity/tag/hashtags/feed/

    only todo is the pubdate

    Avatar of Anton
    Anton
    Participant

    @antonrsa

    Excellent!. Will the feed only be available as a feed for all the hashtags or generated for every single hashtag?

    Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    right now for each tag – just like the feed for atmention level. (if you want an overall – ie all activity records which have some #hashtag – i need to see if the bp search_term param can support wildchars)

    Avatar of Anton
    Anton
    Participant

    @antonrsa

    @nuprn1 Looks great. Can you send me the updated file?

    Avatar of rich! @ etiviti
    rich! @ etiviti
    Participant

    @nuprn1

    i went ahead and updated the repo with a per hastag feed and the title filter – i’ll have to look into an “all hashtag” feed when time permits

    Avatar of juanpons14
    juanpons14
    Member

    @juanpons14

    Hi! Nice plugin, but thinking about it, and after getting the search for hashtags (It’s really easy, you just have to find activities) I was wondering why this plugin does not put anything in the database.
    The tags of wordpress, are housed in the database, so, for example, make widgets and extract according to relevance.

    Following this idea I decided to look a little plugin files, and I managed to create a database and staying there the hashtags of activities, establishing a numerical score, to avoid repeating hashtags, and to remove them by relevance in a widget.

    For if anyone is interested in this role, I pass the code I developed in just 30 minutes, so nor is it the best.

    We must create a table in our database:
    CREATE TABLE IF NOT EXISTS `wp_hashtags` (
    `id` int(11) NOT NULL auto_increment,
    `name` text NOT NULL,
    `link` text NOT NULL,
    `count` int(11) NOT NULL default ’1′,
    `date` date NOT NULL,
    `new_date` date default NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

    After this, we must open the file bp-activity-hashtags.php which is in the plugin folder and find this:

    ` $content = preg_replace( $pattern, ‘ root_domain . “/” . $bp->activity->slug . “/”. BP_ACTIVITY_HASHTAGS_SLUG .”/” . htmlspecialchars( $hashtag ) . ‘” rel=”nofollow” class=”hashtag”>#’. htmlspecialchars( $hashtag ) .’‘, $content );
    }
    }
    return $content;`

    Then, replace that code with this:

    ` $content = preg_replace( $pattern, ‘ root_domain . “/” . $bp->activity->slug . “/”. BP_ACTIVITY_HASHTAGS_SLUG .”/” . htmlspecialchars( $hashtag ) . ‘” rel=”nofollow” class=”hashtag”>#’. htmlspecialchars( $hashtag ) .’‘, $content );
    }
    }
    $sql = $wpdb->query(“SELECT name FROM wp_hashtags WHERE name = ‘$hashtag’”);
    if($sql) {
    $date = date(“Y-m-d”);
    $sql = “UPDATE wp_hashtags SET count = count + 1, new_date = ‘$date’ WHERE name = ‘$hashtag’ LIMIT 1″;
    $res = $wpdb->query($sql);
    } else {
    $date = date(“Y-m-d”);
    $sql = “INSERT INTO wp_hashtags (id, name, link, count, date) VALUES (”,’$hashtag’,’$content’,”,’$date’)”;
    $res = $wpdb->query($sql);
    }
    return $content;`

    Save de file, and replace the file by the original en the plugin folder. Now when an user post a #hashtags you will have the hashtags in a database table call wp_hashtags and now you can extract the hashtags by relevance “count” using an SQL statement and a loop php or maybe someone can dig a little deeper. I think that is progress.

    NOTE: Old hashtags will not be stored in the database, only since the code is implemented.

    If anyone has any questions or suggestions, feel free to ask.

    Avatar of designnz
    designnz
    Participant

    @designnz

    Hi there guys I know there hasnt been any activity here in a long time it just a question any help would be much appreciated! I want to include a custom field in my custom post type that records hastags and my posts will come up when related hastags are selected.

    Thanks
    Jon

    Avatar of investoreports
    investoreports
    Participant

    @investoreports

    Hi there

    Am getting a “page not found” for the hashtag results – any ideas?

    Same for the Edit Activity streams plugin…

    Regards
    Simon

Viewing 20 replies - 26 through 45 (of 45 total)

You must be logged in to reply to this topic.