vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=323088

Obtaining Unique URL for each page? (VB5.2)
by karlm
23 Jul 2016 13:39

How would I obtain the unique URL for a page so I can call it from PHP/HTML, please?

I guess it would be similar to the post identifier, clicking on it gives the URL to that post in a popup window.

Replicant 23 Jul 2016 13:54

1 Attachment(s)
So you want to get the url of a nodeid? Where is the nodeid coming from? See the attachment for php usage of the function getAbsoluteNodeUrl()

This can also be done entirely with javascript and AJAX calling route/getAbsoluteUrl

karlm 23 Jul 2016 15:27

Forgive my ignorance, I'm reasonably experienced in programming of old but today's languages are somewhat over my head.

So please allow me to ask for an answer that I can digest a little easier.

I need a means to call the URL of the current page so a script can ensure it has the correct values. In short, I'm looking at replacing the 'comments' used in 'articles' of VB5 so instead of a boring plain box with some bot deterrent questions, a guest can leave a comment on each page.

Disqus seems like the obvious answer as although VB5 can have 'guests' commenting, aside from checking IP addresses and such there's no real way to tell one guest from another. With Disqus I get to see who they actually are whilst not having to be a registered member and still retain a high level of moderation over such comments.

They supply a default code to apply to web pages, which I've done.

I edited my 'article' page (default template 36) to have a PHP module at the bottom of the page. I pasted their code into the PHP module and it says I have to find the Unique URL to ensure content isn't mixed up with other content.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So, while you've very kindly assisted with guiding me to what I may need, I have no idea how that is applied in this case.

Here is their explanation for what is needed:
Quote:

These variables should be defined by using your CMS’ or platform’s dynamic values, if available. For example, the Disqus WordPress plugin defines these variables by default using the following PHP values:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I hope this clarifies what I'm looking for and clarifies my absolute lack of comprehension on the topic. :)

Here's an example of where I'm using it (not trying to spam, so please delete this link if it's considered spam)

http://antimisandry.com/articles/cul...enging-picture

Replicant 23 Jul 2016 16:21

Ok, that's pretty easy to do as the information is already in every page. Probably won't need the php module either. There is a canonical url in the header if every page. This can be retrieved and the variable set for disqus using jquery and set to the this.page.url variable. For the this.page.identifier variable, you can use the pageData.nodeid variable that is embedded in the page.

Here is what the header code for the canonical url looks like.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


karlm 23 Jul 2016 18:22

Yeah, all of that flew like Concord over my head lol...

I received your PM and will eagerly accept your kind offer :)

Replicant 24 Jul 2016 05:10

Open one of the articles on your site, enable sitebuilder, drag an ad module down below the article, edit the module, paste this code into an ad and save. You can select who sees it during the configuration of the module.
You will also want to disable comments for Articles to make the comment box disappear. You may have to hide the comments disabled message with CSS. I started a Discus account and tested the functionality, it works as expected. I am a bit confused as to why use the outside forum since the guest user has to signup for a discus account to post. Why not just have the user sign up to your forum instead?


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


karlm 24 Jul 2016 13:38

The reason being is because there are already hundreds of thousands of Disqus users registered, this enables some level of control over guest comments without each & every guest being named "guest". I'm just trialling it for now...

Thank you so kindly for your assistance with the code & support in how to implement it. I really appreciate the help.

noypiscripter 25 Jul 2016 04:27

Instead of looping through all the link tags and looking for canonical, the canonical href can be retrieved using a single line:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

--------------- Added 25 Jul 2016 at 04:29 ---------------

If the discus code is inserted after the jQuery include, you can also use:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Replicant 25 Jul 2016 04:53

Quote:

Originally Posted by noypiscripter (Post 2573866)

If the discus code is inserted after the jQuery include, you can also use:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Thanks Glenn. The code is in an ad module for easy usergroup administration without writing custom templates. This is the Jquery code I had come up with originally. I battled this one because the code is before jquery loads. I'm not very proficient with pure JS so I have to hit places like Stack Exchange for answers to get it done. I didn't particularly like the looping, but this one was taking way too much time and there aren't that many link tags to cause a severe performance hit, so I rolled with it.

noypiscripter 25 Jul 2016 15:34

Actually, if you use window onload handler, you can safely use jQuery inside the handler as the jQuery has been loaded completely at that point even if the script was inserted before the jQuery include. Although I don't like using window onload for this particular issue because if a thread has multiple large images, the browser has to wait for them to be completely loaded before the Discus code is executed and initialized. And besides, window onload is not necessary.

I recommend using pure JS without window onload.

final kaoss 16 Feb 2019 02:17

Hi thanks for some of these helpful replys, I'm trying to add disqus to the vbulletin archive. (using vb4 though)

Any help on what to fill in here?

this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable


All times are GMT. The time now is 13:48.

Powered by vBulletin® Version 3.8.12
Copyright © 2019, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.