PDA

View Full Version : Display site stats on external page?


globofan
05-11-2009, 01:11 PM
My site forums are located at.. www.mysite.com/forums

But the homepage (www.mysite.com/index.php) is running a basic php/html news system. On the homepage how would i show the latest posts in the form and other details? Its outside the actual forum root so i do not know how it would work


I also need to know how to make an external php file to show the user profile info (latest user posts etc)..
something like www.mysite.com/showprofile.php?username=admin (shows admins profile info)

Lynne
05-11-2009, 02:31 PM
You will have to do a query in your php page in order to get the latest posts. You can go find a modification that does the latest posts and just use the same query and templates to spit out the information on your page. You'll need to include global.php, just do it like this:
chdir('/path/to/your/forums');
require_once('./global.php');

As for creating another page, this should help - [How-To] vBulletin API Basics: Creating Custom Pages & Misc. (https://vborg.vbsupport.ru/showthread.php?t=98009)

Byron
05-12-2009, 07:48 AM
hmm, i just ask the same question also

https://vborg.vbsupport.ru/showthread.php?p=1809212#post1809212

Maybe we can help out each other.

SVTCobraLTD
05-12-2009, 02:16 PM
Do a search for displaying content on external page. There are ones for logging in and displaying the stats.

globofan
05-12-2009, 02:30 PM
I followed that method exactly and just got a blank page? that guide was made in 2004, surley it won't work with the newest vb version?

Lynne
05-12-2009, 03:01 PM
Yes, it works with the newest version. If you have a blank page, then you did something wrong. You may post your code here - just make sure you put php or html (depending) tags around your code.

globofan
05-12-2009, 03:15 PM
Lynne, thanks for this help :D

forum is located at mysite.com/forums
this script is located at mysite.com/file/vbtest/test.php and the .html is in that folder too.


test.php file code..

<?php

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
// change the line below to the actual filename without ".php" extention.
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value throughout every PHP file of any given vBulletin installation.

define('THIS_SCRIPT', 'test');

// #################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array(

// change the lines below to the list of actual templates used in the script
'test_mytesttemplate1',

);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ########################## REQUIRE BACK-END ############################

chdir('/home/netgoon/public_html/domains/mysite.com/forums');
require_once('./global.php');

// #################### HARD CODE JAVASCRIPT PATHS ########################
$headinclude = str_replace('clientscript', $vbulletin->options['bburl'] . '/clientscript', $headinclude);

// ################################################## ######################
// ######################### START MAIN SCRIPT ############################
// ################################################## ######################

$navbits = array();
// change the line below to contain whatever you want to show in the navbar (title of your custom page)
$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');

// change the line below to contain the name of the actual main output template used in your script
eval('print_output("' . fetch_template('test_mytesttemplate1') . '");');
?>

test_mytesttemplate1.html code..


$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle]</title>
</head>
<body>

$header
$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">My Custom Page Title</td>
</tr>
<tr>
<td class="alt1">Other Bluff...</td>
</tr>
</table>

$footer
</body>
</html>

Lynne
05-12-2009, 03:42 PM
This line does not look correct according to where you said your test site was located:
chdir('/home/netgoon/public_html/domains/mysite.com/forums');
(You said "this script is located at mysite.com/file/vbtest/test.php and the .html is in that folder too.")

Also, what you posted and said you saved as "test_mytesttemplate1.html" is not supposed to be a file. It is supposed to be a template named "test_mytesttemplate1"

globofan
05-12-2009, 05:36 PM
Ahh! worked perfect thanks :)

I made a html page instead of a template! :p