Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
lenstudio
Topic Author
Posts: 15
Joined: 01 Mar 2016, 04:13

How can I get the PageID ?

21 Jan 2017, 23:26

Hi~~ Just want to know is there a GetPageID function for the custom script use for locate the page?

eg.  <script src="http://aaa.com/api.js?id=<?=$PageID?>"></script>

So I can use the script at [Custom Javascript] section for the pages

Many thanks for your help :)
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14007
Joined: 30 Sep 2006, 03:37

Re: How can I get the PageID ?

22 Jan 2017, 05:34

What ID are you looking for? What will you use it for? You mean to get CURRENT page name or something?
 
User avatar
lenstudio
Topic Author
Posts: 15
Joined: 01 Mar 2016, 04:13

Re: How can I get the PageID ?

22 Jan 2017, 20:32

I just want to use a function like Disqus , ( Cause Disqus had been blocked in China :( ), So I found another services in China, but the function needs a PageID to distinguish the message. 

eg. if use with wordpress template:
Code
<div id="SOHUCS" sid="<?php the_ID(); ?>" ></div>
<script charset="utf-8" type="text/javascript" src="http://changyan.sohu.com/upload/changyan.js" ></script>
<script type="text/javascript">
window.changyan.api.config({
appid: 'cysO2W0K1',
conf: 'prod_8952fb94728347ccdc0f79b420cf6f95'
});
</script>

the_ID()  should be the current page id.

So is there any function to get it ?

Here is the FAQ: 
https://translate.google.com/translate? ... edit-text=

Thank you so much !
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14007
Joined: 30 Sep 2006, 03:37

Re: How can I get the PageID ?

22 Jan 2017, 23:14

From javascript, you should be able to use:
Code
x3_settings.id
You need to be cautious about when you trigger your custom script though. The ID is only available after page is loaded (bottom of page), and what about when you navigate to the page from the nav (Ajax)? You should really be using the x3_page_load() event function (settings -> custom - > custom JS) to trigger your script. Let me know if you need any help.
 
User avatar
lenstudio
Topic Author
Posts: 15
Joined: 01 Mar 2016, 04:13

Re: How can I get the PageID ?

23 Jan 2017, 08:52

:thumbsup: :thumbsup: :thumbsup: :thumbsup:  Thank you so much! 
Code
function x3_load_page(){
document.getElementById("bqs").innerHTML='<div id="SOHUCS" sid="'+x3_settings.id+'"></div>';
window.changyan.api.config({
appid: 'cysO2W0K1',
conf: 'prod_8952fb94728347ccdc0f79b420cf6f95'
});
}
It works!! 
 
User avatar
mjau-mjau
X3 Wizard
Posts: 14007
Joined: 30 Sep 2006, 03:37

Re: How can I get the PageID ?

23 Jan 2017, 10:45

Nice!  :star: :punch: :star: