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 16, 2010
9:11 pm
Member
Forum Posts: 206
Member Since:
Dec 8, 2009
Offline

Okay, so for a moron like me, How do I implement this to my forum?

Aug 16, 2010
9:47 pm

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

its detailed quite well in this thread… you have to make it a program hook… details on program hooks are on our wiki… then my thread tells you which hook to use and the exact code (minus your twitter id) to use…

Nov 19, 2010
1:12 pm
Member
Forum Posts: 103
Member Since:
May 8, 2010
Offline

Ok, so ive implementet the FB like and Tweet .. and it works … however, the FB like function seems to span the entire forum and not just one topic .. so if i click "like" i one topic, no matter what topic i then read "i like" … so the topic like count is actually an entire fourm like, instead of just the one topic.

But im still facing a problem with adding a Facebok Share button .. or not so much adding the button, cause that is pretty simple, but getting it to work right is a bit of a bother.

 

Ive place the FB share button in the: function sf_render_topic_printicon($topicid), replacing the printer icon. Ive tested placing the share button different places on the topic page, and also tried placing the post permalink directly in facebook .. the results are the same.

 

What happends is, the FB share cant seem to resolve the topic title, instead it display the url to the post. Also it doesnt interpet the content text as exerpts, but merely writes "Forum" as a link.. The thumbnail function works ok…

 

I reckon the best way to see this for your self is to go to this page and try and click the big Facebok button in the sfheading

http://www.kiteboarding.dk/for…..11-hadlow/

 

Also do you guys think its possible to automate the tweet function, so that each new topics gets tweeted automaticly when posted?

 

Nov 19, 2010
8:01 pm

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

it wont matter 'where' you locate it – it isnt location dependent as long as forum data is set up…

but  you are not doing a 'like' there, so not sure what you are doing… assuming you found the js somewhere and properly passed the info…

but in the 'like' example I have clearly is topic based and not forum based…  so would suspect your code, but you would have to post it for me to look at…

you certainly could make it tweet every post using our program hooks…   there is one fired when a post is saved… you would just need to access the twitter api with the data (which is made available to the hook)…

Nov 20, 2010
4:39 am
Member
Forum Posts: 103
Member Since:
May 8, 2010
Offline

This is the code i use for the LIKE and the TWEET. Its placed in the file sf-hook-template.php in line 389.

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="kiteboardingdk">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;
    }

Nov 20, 2010
9:15 am

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

something else must be at play here too… because when I click on the FB link on your site, I dont get a 'like' action, I get a 'share' action…

DOH! wrong link…

but it seems working???

you do have a bunch of js errors on that page…  OA_SHow is not defined…  maybe a dozen times

Nov 20, 2010
11:05 am
Member
Forum Posts: 103
Member Since:
May 8, 2010
Offline

Please advice, on what page do you get Js errors, im using web developer to scan for errors, and it only locates CSS errors on that page … not to say there arent any errors, cause im not that skilled in the JS department ^^

 

Yikes, ok i see a lot of FB and Stat JS errors ..

Nov 20, 2010
2:33 pm

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

I was seeing them on the forum topic you linked to above…   I like to use firefox with firebug as I think its much better… js errors show up in the console…

Jan 29, 2011
5:40 am
Giuseppe I.
Guest

Hi I would like to use the second example but whre should i drop the code?

Inside the two () or inside the return ''?

Do I need to replace the entire sf_hook_post_topic_top_pagelinks() hook string or just add the code starting with:

function sf_hook_post_topic_top_pagelinks($forumid, $topicid)
        {
            $topicname = sf_get_topic_name_from_id($topicid);
I am stuck.

Thank you

Jan 29, 2011
5:56 am
Giuseppe I.
Guest

Done it!

Thank You anyway. All need to be replaced.

Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online: wazina
66 Guest(s)

Currently Browsing this Page:
2 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)