Posted May 19, 201510 yr How do i print canonical url to code?example<div class="fb-like" data-href="CANONICAL URL HERE" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>I wanna put that to articles
May 20, 201510 yr How do i print canonical url to code?example<div class="fb-like" data-href="CANONICAL URL HERE" data-layout="standard" data-action="like" data-show-faces="false" data-share="true"></div>I wanna put that to articles.If you really wanna do this then I guess you need to add the ..rel="canonical"before the href="siteURL" ..Not sure you need to use data-href or href .. maybe try href first ..Another thing .. if you wanna use it with Facebook then you need to use .. og:url ?canonical is something for search engines and og:url is something Facebook uses .. .
May 20, 201510 yr He's trying to use it for a custom Facebook button of some sort.Assuming you are working from within the record view template, you would use:$record->url()to get the url object of the currently viewed database record(without any comment pagination or fragments present, so the canonical URL that is), used or cast as a string will return the URL itself. Edited May 20, 201510 yr by Marcher Technologies
May 20, 201510 yr Author He's trying to use it for a custom Facebook button of some sort. Assuming you are working from within the record view template, you would use: $record->url() to get the url object of the currently viewed database record(without any comment pagination or fragments present, so the canonical URL that is), used or cast as a string will return the URL itself. Perfekt!
May 20, 201510 yr Author Yes, this works data-href="{$record->url()}" How about forums? Edited May 20, 201510 yr by Owdy
May 20, 201510 yr Yes, this works data-href="{$record->url()}" How about forums? that method is standardized. $topic->url(), $forum->url(), etc, any node that has a public url will have that method, as will any content item.
May 25, 201510 yr Author data-href="{$forum->url()}" I dont get it. Now that gives blank page edit got it. should be data-href="{$topic->url()}" Edited May 25, 201510 yr by Owdy
Archived
This topic is now archived and is closed to further replies.