vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Custom vB5 page? (https://vborg.vbsupport.ru/showthread.php?t=321394)

michaeld42 01-04-2016 10:11 PM

Custom vB5 page?
 
Some years ago I used Lynne's excellent article "[HOW TO - vB4] Create your own vBulletin page" (https://vborg.vbsupport.ru/showthread.php?t=228112) to make a vB4 page outside the vB4 forum that used vBulletin variables and member info to build a Google Maps page that could store member's map data such as points of interest, routes, etc. (One such page is at http://www.roadtripamerica.com/maps/mapwizard.php)

Is this possible to do in vB5, and keep the same URL without using a redirect? It seems that the customizable pages in vB5, able to access user info, are only forum subdirectories. Right now I don't see how to access vB variables and user data from a page outside the forum. I would love to see something like Lynne's article for vB5.

Thanks,

Michael H. Dickman

Replicant 01-04-2016 11:45 PM

I use ajax to get logged in user info when needed via javascript.

http://yoursite.com/[forum root]/ajax/api/user/fetchCurrentUserinfo

This will yield a plethora of useful and useless information in a JSON object that you can use in your custom page. The following example will report back the username of the logged in user or alert to login.

Example, edit the url in the code.:
Code:

<html>
<body>

<h1 class="username"></h1>

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
        $.ajax({
                url: 'http://yoursite.com/[forum root]/ajax/api/user/fetchCurrentUserinfo',
                type: "POST",
                dataType: 'json',
                success: function(response) {
                        if (response && !response['errors'] && response['userid'] !=0) {
                                $( ".username" ).append( response['username']  );
                        }
                        else {
                                alert('You must login!');
                        }
                }
});
</script>

</body>
</html>


Lynne 01-05-2016 04:18 PM

You don't want to just go to Site Builder > New Page and then just add an HTML or PHP Module onto the page? That will create a 'custom' page within vB5.

vB5_User::get('userid') is the variable you would use in a PHP module to get the userid. And vB5_User::get('username') is the username.

michaeld42 01-05-2016 08:53 PM

I didn't see a way to use Site Builder that wouldn't generate a file in a subdirectory of the Forum. Is there one? Maybe I just overlooked it.

Lynne 01-06-2016 05:12 PM

So you want to create a page that does not have the same main URL of your forum? You would need to create it totally separate from vbulletin if that is the case.

michaeld42 01-06-2016 08:51 PM

Yes, the issue is that the original page e.g., www.roadtripamerica.com/maps/mapwizard.php, is not a forum subdirectory, and using a redirect would affect SEO. So when upgrading from vB4 to vB5 ideally we want to keep the same URL without a redirect. But if there's no way to generate a page outside the forum subdirectory using Site Builder then I need some other way to access the vB member variables so the correct info can be displayed. Using Ajax seems doable, even if it's a bit of a sledgehammer approach.


All times are GMT. The time now is 10:09 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01004 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete