A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
I need to add a piece of javascript code in topic line on post page (for Twitter!)
Aug 9, 2010
1:09 pm
Member
Forum Posts: 17
Member Since:
Aug 4, 2010
Offline

great.

i have another small question.

can I make it so this script only shows up on certain sections of the forum, similar to the way this is possible in wordpress.

Aug 9, 2010
1:46 pm

SP Master
Forum Posts: 22240
Member Since:
Nov 9, 2008
Offline

You might find these template tags useful… Read the note at the top before using them…

Yellow Swordfish
Aug 9, 2010
4:21 pm
Member
Forum Posts: 17
Member Since:
Aug 4, 2010
Offline

thanks

what about a specific category section?

Like if I only want Android affiliate products to show up on the Android forums.

Aug 9, 2010
4:48 pm

SP Master
Forum Posts: 22240
Member Since:
Nov 9, 2008
Offline

Look at the hooks. many of them pass in the id of the group, forum or topic so it easy to check. As in if($forumid = 2) or some such.

Yellow Swordfish
Aug 9, 2010
5:11 pm
Member
Forum Posts: 17
Member Since:
Aug 4, 2010
Offline

gotcha. thanks.

Aug 14, 2010
10:31 pm

SP Master
Forum Posts: 23698
Member Since:
Dec 10, 2006
Offline

I have taken mikemacias great start here and extended it to use the new twitter tweet me button as well as added a facebook like me button.

you can see them both active here on this site.  I have chosen to put them under the topic tags using the sf_hook_post_topic_top_tags() hooks…  If you want them above the topic tags, just use the sf_hook_post_topic_top_pagelinks() hook.

Here is what I replaced the hook template with:

 

function sf_hook_post_topic_top_tags($forumid, $topicid)
    {
        $tweetme = '<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="SimpleForum">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
        $url = urlencode(sf_permalink_from_forumid_and_topicid($forumid, $topicid));
        $likeme = '<iframe src="http://www.facebook.com/plugins/like.php?href='.$url.'&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=tahoma&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:20px;" allowTransparency="true"></iframe>';
        $out = '<div class="sfalignright">';
        $out.= $likeme;
        $out.= $tweetme;
        $out.= '</div>';
        return $out;
    }

and thanks to mikemacias for getting us going! enjoy!

Aug 14, 2010
10:37 pm

SP Master
Forum Posts: 23698
Member Since:
Dec 10, 2006
Offline

ooppsss… sorry, actually moved it back to the post pagelinks since the topic tags hooks arent fired if you arent using tags (like some of our forums).

Aug 14, 2010
11:07 pm

SP Master
Forum Posts: 23698
Member Since:
Dec 10, 2006
Offline

or if you prefer to simply have the topic name itself (the above gives you page name and forum name too) for the tweet text, then use this:

function sf_hook_post_topic_top_pagelinks($forumid, $topicid)
    {
        $topicname = sf_get_topic_name_from_id($topicid);
        $tweetme = '<a href="http://twitter.com/share" class="twitter-share-button" data-text="'.$topicname.'" data-count="horizontal" data-via="SimpleForum">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
        $url = urlencode(sf_permalink_from_forumid_and_topicid($forumid, $topicid));
        $likeme = '<iframe src="http://www.facebook.com/plugins/like.php?href='.$url.'&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=tahoma&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:20px;" allowTransparency="true"></iframe>';
        $out = '<div class="sfalignright">';
        $out.= $likeme;
        $out.= $tweetme;
        $out.= '</div>';
        return $out;
    }
Aug 15, 2010
7:50 am
Richard Hay
Guest

You will need to change the Twitter ID in the Via spot to yours if you want it to have your account reflected in the Tweet.


via="WinObs" for instance or whatever your Twitter name is.


 

Aug 15, 2010
1:41 pm

SP Master
Forum Posts: 22240
Member Since:
Nov 9, 2008
Offline

Good point. Thanks for adding this…

Yellow Swordfish
Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: wazina
65 Guest(s)

Currently Browsing this Page:
1 Guest(s)

See All Online Activity

Top Posters:

-Radio-: 1251

Lee H: 606

Luffer: 535

Conrad_Farlow: 504

jim: 478

neon: 263

ovizii: 240

Tal: 240

Member Stats:

Guest Posters: 2626

Members: 7364

Moderators: 1

Admins: 2

Forum Stats:

Groups: 5

Forums: 16

Topics: 10905

Posts: 79605

Moderators: Brandon C (162)

Administrators: Yellow Swordfish (22240), Mr Papa (23698)