Open GoogleCodeExporter opened 8 years ago
It just occurred to me that it might be possible to put these values in
directly using JavaScript (since this is JavaScript code). If that is the case,
can someone please let me know?
Original comment by markd...@gmail.com
on 29 Jul 2011 at 4:58
1. We need to have unique page id.
Vosao CMS uses internally URL as a unique page identifier.
$page.id will not work as it is changed if you create new page version.
I suggest to use page attribute for holding page key.
2. We can use JavaScript to provide Disqus with page id.
This can be done using page template where you define javascript id variable
and then use it in Disqus code snippet.
In page template:
<script type="text/javascript">var pageGUID = '$page.attribute.guid';</script>
(create page attribute "guid")
And in Disqus:
var disqus_identifier = pageGUID;
Original comment by kinyelo@gmail.com
on 29 Jul 2011 at 8:49
Thanks very much for your help.
I didn't like the idea of having to manually specify the ID for every page, so
I've come up with a compromise solution. It defaults to the Friendly URL (e.g.
"/blog/my-first-blog-entry") as the Disqus ID, but this can be overridden by
adding a disqusID attribute to a page. That way if anything gets moved around
in the future, the existing ID can be manually kept the same, but otherwise
everything can be left to handle itself automatically.
In the <head> section of the template, put:
<script type="text/javascript">
if("$page.attribute.disqusID"=="$"+"page.attribute.disqusID") {
var disqusID = "$page.friendlyURL";
} else {
var disqusID = "$page.attribute.disqusID";
}
</script>
In the Disqus plugin options, put:
var disqus_identifier = disqusID;
Still, I wonder if it would be realistic and helpful to add functionality like
this to the Disqus plugin out of the box?
Original comment by markd...@gmail.com
on 29 Jul 2011 at 10:06
I've gone a little bit further again. Just posting the code in case its of use
to anyone else. This time I've got the main domain that I want to ensure is
used for the permalink coded in. Not essential, but at least it means both
recommended fields are being provided.
In the template (note that www.yourdomain.com needs replacing with your domain):
<script type="text/javascript">
if("$page.attribute.disqusID"=="$"+"page.attribute.disqusID") {
var disqusID = "$page.friendlyURL";
} else {
var disqusID = "$page.attribute.disqusID";
}
var fullPermalink = "http://www.yourdomain.com" + "$page.friendlyURL";
</script>
In the embedded Disqus code:
var disqus_identifier = disqusID;
var disqus_url = fullPermalink;
Original comment by markd...@gmail.com
on 29 Jul 2011 at 11:31
Original issue reported on code.google.com by
markd...@gmail.com
on 29 Jul 2011 at 4:45