Owdy Posted May 19, 2015 Share Posted May 19, 2015 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 Link to comment Share on other sites More sharing options...
不中用 Posted May 20, 2015 Share Posted May 20, 2015 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 .. . Link to comment Share on other sites More sharing options...
Marcher Technologies Posted May 20, 2015 Share Posted May 20, 2015 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. Link to comment Share on other sites More sharing options...
Owdy Posted May 20, 2015 Author Share Posted May 20, 2015 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! Link to comment Share on other sites More sharing options...
Owdy Posted May 20, 2015 Author Share Posted May 20, 2015 Yes, this works data-href="{$record->url()}" How about forums? Link to comment Share on other sites More sharing options...
Marcher Technologies Posted May 20, 2015 Share Posted May 20, 2015 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. Link to comment Share on other sites More sharing options...
Owdy Posted May 25, 2015 Author Share Posted May 25, 2015 data-href="{$forum->url()}" I dont get it. Now that gives blank page edit got it. should be data-href="{$topic->url()}" Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.