Customizing SMF > SMF Coding Discussion

Help with topic urls

(1/3) > >>

Owdy:
I added fb like button in topics, main code is this.

--- Code: ---<div class="fb-like" data-href="" data-send="true" data-width="450" data-show-faces="true"></div>
--- End code ---

Topics have multiple pages, lets say

index.php?topic=10082.0
index.php?topic=10082.25
index.php?topic=10082.50

etc

How can i print that main topic url in all of those topic pages in to this

--- Code: ---data-href=""
--- End code ---
?


--- Code: ---data-href="$context['page_index']"
--- End code ---
or something.

Does this make any sense?

Arantor:
Inside the topic view you can use $context['canonical_url'] in SMF 2 to achieve this. There's no similar equivalent in SMF 1.1.x.

Owdy:
I tryed this:



--- Code: ---<div class="fb-like" data-href="', $context['canonical_url'], '" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true" data-font="arial"></div>
--- End code ---

If im in index.php?topic=9233.75 , it prints that, not index.php?topic=9233.0

Arantor:
It's supposed to. .75 refers to that page of the topic. Having it refer to the main topic as a whole is actually not that great an idea in the scheme of things (especially as it'll argue with the canonical URL FB will be seeing out of your page)

Owdy:
well i guess it better than index.php?topic=10233.msg229440#new or similar. But small issue is, if someone hit "like" in page 3, he likes that page, not main topic. Hmmm

Navigation

[0] Message Index

[#] Next page

Go to full version