vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   template driven pages (https://vborg.vbsupport.ru/showthread.php?t=63792)

Jakeman 04-12-2004 07:34 PM

template driven pages
 
Re: http://www.vbulletin.com/forum/showthread.php?t=101325

Create a PHP file with this code. Change the red code appropriately. This will display a page within your forum layout where the page contents are the contents of the template you specify.

Code:

<?php

// GO TO FORUM DIR
chdir('/full/path/to/forum/directory');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'script_name');
require_once('./global.php');

// GENERIC_SHELL VARS
$pagetitle = "Title of Page";
$HTML = ""; // PIECED TOGETHER IN SCRIPT

eval('$HTML = "' . fetch_template('name of template') . '";');

eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');

?>


fonzerelli_79 04-12-2004 08:08 PM

thanks jake

for some reason the $navbar variable wont work - is there something i have to include in the php code to be able to include the navbar template

Jakeman 04-12-2004 11:34 PM

Try adding this code before the last eval line:

PHP Code:

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

This will at least call the template. I'm not sure how the nav location will be reported since it's an external script.

fonzerelli_79 04-12-2004 11:38 PM

yeah that worked - thanks

filburt1 04-13-2004 12:40 AM

Quote:

Originally Posted by Jakeman
Try adding this code before the last eval line:

PHP Code:

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

This will at least call the template. I'm not sure how the nav location will be reported since it's an external script.

PHP Code:

$navbits = array("" => "The Foo Page"); 


blairwarlock 04-19-2004 02:27 AM

Quote:

Originally Posted by filburt1
PHP Code:

$navbits = array("" => "The Foo Page"); 


When inserting this variable, I get a nested link with the main home page at the top. However, the open folder icon below it shows no text next to it. Shouldn't it read "The Foo Page" (or whatever text you use)?

lazserus 04-22-2004 05:02 AM

Please pardon my ignorance, but what I'm getting from this is that this creates the option to stick any current (or custom) template into an entirely new page with a vBulletin theme. This is all well and good (from my retarded little standpoint), but I'm not too keen on custom making a template w/o guidance. My webmaster and myself are testing this hack and the setup is simple enough but we're having problems adding content. :ermm: It's just that we don't quite understand vB3 yet. Any guidence?

fonzerelli_79 04-22-2004 09:07 AM

Quote:

Originally Posted by blairwarlock
When inserting this variable, I get a nested link with the main home page at the top. However, the open folder icon below it shows no text next to it. Shouldn't it read "The Foo Page" (or whatever text you use)?

use this instead

PHP Code:

$navbits[lastelement] = "The Foo Page"

:)

hollyboy 05-01-2004 09:58 AM

<a href="http://www.interfans.org/forum/rules.php" target="_blank">http://www.interfans.org/forum/rules.php</a>

I get this error:
Warning: chdir(): No such file or directory (errno 2) in /home/interfan/public_html/forum/rules.php on line 4

And what do I have to add in the new template?

Boofo 05-01-2004 01:41 PM

Quote:

Originally Posted by hollyboy
http://www.interfans.org/forum/rules.php

I get this error:
Warning: chdir(): No such file or directory (errno 2) in /home/interfan/public_html/forum/rules.php on line 4


And what do I have to add in the new template?

Try this:

PHP Code:

$navbits = array();
$navbits[$parent] = 'Forum Rules';

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

Chnage Forum Rules to what you want the navtitle to say.

hollyboy 05-01-2004 03:02 PM

where do I have to copy that?
Sorry not very confident with php

Boofo 05-01-2004 03:07 PM

Put it instead of this:

PHP Code:

$navbits[lastelement] = "The Foo Page"

or whatever else you used for that line. ;)

hollyboy 05-01-2004 04:21 PM

I don't know what u r talking about...:(
My code is this one:

<?php

// GO TO FORUM DIR
chdir('/full/path/to/forum/directory');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'script_name');
require_once('./global.php');

// GENERIC_SHELL VARS
$pagetitle = "Title of Page";
$HTML = ""; // PIECED TOGETHER IN SCRIPT

eval('$HTML = "' . fetch_template('name of template') . '";');

eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');

?>

Boofo 05-01-2004 04:25 PM

Quote:

Originally Posted by hollyboy
I don't know what u r talking about...:(
My code is this one:

<?php

// GO TO FORUM DIR
chdir('/full/path/to/forum/directory');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'script_name');
require_once('./global.php');

// GENERIC_SHELL VARS
$pagetitle = "Title of Page";
$HTML = ""; // PIECED TOGETHER IN SCRIPT

eval('$HTML = "' . fetch_template('name of template') . '";');

eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');

?>

Put the code I gave you right BEFORE this line:

PHP Code:

eval('print_output("' fetch_template('GENERIC_SHELL') . '");'); 


hollyboy 05-01-2004 05:26 PM

<a href="http://www.interfans.org/forum/rules.php" target="_blank">http://www.interfans.org/forum/rules.php</a>
error
I am getting confused about the code to use now. Can u please say exaclty all the code I have to have in my rules.php page.
Thanks

Boofo 05-01-2004 05:31 PM

Here's what I use for my rules.php file:

PHP Code:

<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''rules'); // change this depending on your filename
// ################### 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(
    
'rules'
);

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

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

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

$navbits = array();
$navbits[$parent] = 'Forum Rules';

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

?>


hollyboy 05-01-2004 08:38 PM

now I get this http://www.interfans.org/forum/rules.php?
:(

Scrub 05-01-2004 08:53 PM

What is in the template you're trying to call?

hollyboy 05-01-2004 09:22 PM

I have to put the rules of my forum, but I don't know how.

Synicide 05-01-2004 09:24 PM

Quote:

Originally Posted by Boofo
Here's what I use for my rules.php file:

PHP Code:

<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''rules'); // change this depending on your filename
// ################### 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(
    
'rules'
);

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

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

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

$navbits = array();
$navbits[$parent] = 'Forum Rules';

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

?>


That's the way I laid out my templates (per Gary W's method) and it worked perfectly. :]

hollyboy 05-01-2004 09:52 PM

should I copy this?
and in the template?

Oleks 05-31-2004 05:07 AM

Quote:

Originally Posted by Jakeman
Re: http://www.vbulletin.com/forum/showthread.php?t=101325

Create a PHP file with this code. Change the red code appropriately. This will display a page within your forum layout where the page contents are the contents of the template you specify.

Code:

<?php

// GO TO FORUM DIR
chdir('/full/path/to/forum/directory');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'script_name');
require_once('./global.php');

// GENERIC_SHELL VARS
$pagetitle = "Title of Page";
$HTML = ""; // PIECED TOGETHER IN SCRIPT

eval('$HTML = "' . fetch_template('name of template') . '";');

eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');

?>






Jakeman,
This php file is working fine.

But, I wand to display ?control panel?. I mean this
Board "tree" and Welcome, UserName
User CP FAQ Members List Calendar New Posts Search Quick Links Log Out

How I can do this? What I should add to your code?

Thank you.

Allen Mead 09-09-2004 06:13 PM

Hello,

I'm having a little trouble with this. I've created a php file called Untitled.php which can be seen here:

http://www.astra-mk2.com/Untitled.php

contents of the file are as follows:

PHP Code:

<?php

// GO TO FORUM DIR
chdir('./forum');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''script_name');
require_once(
'./global.php');

// GENERIC_SHELL VARS
$pagetitle "Title of Page";
$HTML ""// PIECED TOGETHER IN SCRIPT

eval('$HTML = "' fetch_template('name of template') . '";');

$navbits = array(); 
$navbits[$parent] = 'Meganman'

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

?>

I can work out how to change the title but not how to insert an html page myhtmlpage.html

The code that's above works beautifully, but it's just the linking to an html as the template and everything that it uses is as I want it.

Any help would be much appreciated.

Allen Mead 09-09-2004 09:52 PM

Sorry, I'm a bit thick when it comes to this sort of thing.

I think i've nailed it down a bit further.

Do i understand it right that I need a script? How and what? and that I obviously need to create the file. Should this have the php or html extension?

Cheers in advanced

Allen Mead 09-10-2004 11:24 AM

Anyone fancy helping the thick??? :nervous:

Dean C 09-10-2004 01:54 PM

php extension :)

Allen Mead 09-10-2004 07:00 PM

still not getting anywhere no matter what i change here, nothing happens

PHP Code:

eval('$HTML = "' fetch_template('name of template') . '";'); 

Lets say I change it to

PHP Code:

eval('$HTML = "' fetch_template('./Articles/Articles_Main.php') . '";'); 

still nothing happens, so obviously i need to change something else but what?

I know I'm terrible, I really need things spelt out!

Allen Mead 09-11-2004 05:51 PM

Anyone??

Allen Mead 09-13-2004 06:49 PM

hmmm, I've had me another go at this, still can't get it, I give up

Allen Mead 09-15-2004 05:48 PM

Right, I'm having another pop at this and at the mo, I still can't get it to work this is what I have:

PHP Code:

<?php 

// GO TO FORUM DIR 
chdir('./forum'); 

// STANDARD VBULLETIN STUFF 
define('NO_REGISTER_GLOBALS'1); 
define('THIS_SCRIPT''Articles_Main'); 
require_once(
'./global.php'); 

// GENERIC_SHELL VARS 
$pagetitle "Title of Page"
$HTML ""// PIECED TOGETHER IN SCRIPT 

eval('$HTML = "' fetch_template('./forum/Articles_Main.php') . '";'); 

$navbits = array(); 
$navbits[$parent] = 'Meganman'

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

?>

Can anyone see where I am going wrong?

Cheers

Allen Mead 09-21-2004 05:21 PM

I take it no-one knows then?

Allen Mead 10-04-2004 06:58 PM

--------------------------------------------------------------------------------

Right, that's it, i still can't get it to work!!! I'll pay for someone to do this for me as long as it's not stupid money. If anyone is interested???

Allen Mead 10-13-2004 07:39 PM

Sorted!! :cool: :cool: Thanks to a guy called David Robinson from Freelancers.net

Well chuffed. You can see a test page here if you're interested http://www.astra-mk2.com/untitled.php

blue_chi 10-13-2004 09:50 PM

Allen,

I am having the same exact problem with my file. Could you please guide me on how to insert my HTML page into it?

Allen Mead 10-14-2004 01:41 AM

Yep no problem blue chi.

This is what has been done with mine:

create your html pages as normal. Then create a template with vbulletin here:

admincp/styles & Templates/Style Manager/Add New Template

call it what you want, mine is html_poloshirts. Copy all the html code into this template.

eg:

PHP Code:

<!-- saved from url=(0022)http://internet.e-mail -->
<!-- saved from url=(0022)http://internet.e-mail -->
<br><table border="0">
  <
tr>
    <
td colspan="3"><font face="Arial, Helvetica, sans-serif"><b><i><img src="Merchandise/Poloshirts/dealer_stripes.gif" width="32" height="18"><font size="5">Astra-mk2.com</font></i><font size="5">
      
Merchandise</font></b></font></td>
  </
tr>
  <
tr>
    <
td colspan="3" height="24">&nbsp;</td>
  </
tr>
  <
tr>
    <
td colspan="3" height="66">
      <
p align="left"><font face="Arial, Helvetica, sans-serif" size="3">We would
        like you to bare in mind that we are not out to make large profits on
        the goods that are forsale
. As <i>Astra-mk2.com</iis <b>not</ba company
        
and is run in Steve's and Allen's spare timeall profits get put back
        into the website to keep it running
.</font></p>
    </
td>
  </
tr>
  <
tr>
    <
td colspan="3" height="35" valign="bottom">
      <
div align="left"><font face="Arial, Helvetica, sans-serif" size="3">The
        following items are available from Astra
-mk2.com.</font></div>
    </
td>
  </
tr>
  <
tr>
    <
td colspan="3">&nbsp;</td>
  </
tr>
  <
tr>
    <
td width="54%" height="81" valign="top">
      <
div align="left"><font face="Arial, Helvetica, sans-serif" size="3">Polo
        Shirts 
Black with the website logo embroidered on the front left breast
        
(your name underneath is optional). Main website sponsor embrodered on
        the back across the shoulders
.</font></div>
    </
td>
    <
td colspan="2" height="268" rowspan="2">
      <
div align="center"><font face="Arial, Helvetica, sans-serif"></font><font face="Arial, Helvetica, sans-serif"><img src="Merchandise/Poloshirts/Polo_shirt_front.jpg" width="269" height="283"></font></div>
    </
td>
  </
tr>
  <
tr>
    <
td width="54%" height="133" valign="top">
      <
p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Polo
        Shirts are available in the following sizes
:-<br>
        
LXL <b>only.<br>
        <
br>
        &
pound;TBA</b> <br>
        
P+&pound;2.00<b><br>
        </
b>Optional Name under logo on front of shirt<b> <br>
        &
pound;1.76</b></font></p>
      </
td>
  </
tr>
  <
tr>
    <
td width="54%" height="273">&nbsp;</td>
    <
td colspan="2" height="273">
      <
div align="center"><img src="Merchandise/Poloshirts/Polo_shirt_back.jpg" width="267" height="266"></div>
    </
td>
  </
tr>
  <
tr>
    <
td width="54%" height="81">&nbsp;</td>
    <
td colspan="2" height="81">
      <
div align="right"><img src="Merchandise/Poloshirts/logo_front.jpg" width="173" height="80"></div>
    </
td>
  </
tr>
  <
tr>
    <
td width="54%">&nbsp;</td>
    <
td width="3%">&nbsp;</td>
    <
td width="43%">&nbsp;</td>
  </
tr>
</
table>

<
br

Create the php file that will reference this new template you created, eg:

untitled.php

PHP Code:

<?php 

// GO TO FORUM DIR 
chdir('./forum'); 

// STANDARD VBULLETIN STUFF 
define('NO_REGISTER_GLOBALS'1); 
define('THIS_SCRIPT''script_name');
require_once(
'./global.php'); 

// GENERIC_SHELL VARS 
$pagetitle "Title of Page"
$HTML ""// PIECED TOGETHER IN SCRIPT 

eval('$HTML = "' fetch_template('html_poloshirts') . '";'); 

$navbits = array(); 
$navbits[$parent] = 'Meganman'

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

Don't forget you will need to change your forum root folder if different to mine and obviously the title page.

You can put this file wherever you want really, doesn't make any difference. Oh, don't forget to upload any images referenced in the new template created. Once done, just replicate for the various pages you want.

blue_chi 10-14-2004 11:19 PM

Thanks so much allen, I managed to get the file show my HTML content. But I was trying to use the PHP include() function, but it doesn't seem to work. Any ideas of how to fix this?

blue_chi 10-14-2004 11:38 PM

OK, I just realised that PHP is not allowed in templates, that's a whole differrent issue then. :S

Mile-O-Phile 11-25-2004 11:26 AM

Quote:

Originally Posted by Jakeman
Code:

<?php

// GO TO FORUM DIR
chdir('/full/path/to/forum/directory');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'script_name');
require_once('./global.php');

// GENERIC_SHELL VARS
$pagetitle = "Title of Page";
$HTML = ""; // PIECED TOGETHER IN SCRIPT

eval('$HTML = "' . fetch_template('name of template') . '";');

eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');

?>




I've stripped my version of this code to:

Code:

<?php

// GO TO FORUM DIR
chdir('./forum');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS', 1);
//define('THIS_SCRIPT', 'script_name');
require_once('./global.php');

// GENERIC_SHELL VARS
$pagetitle = "Talk History Test";
$HTML = ""; // PIECED TOGETHER IN SCRIPT

eval('$HTML = "' . $bbuserinfo[username] . '";');
eval('print_output("' . $bbuserinfo[username]. '");');
?>

This is because I only want to get the username from the forum to display on an independent web page. However, it keeps on creating a new HTML page with the user's name. So, I'd like to be able to convert it into a function (called get_form_user() ) that I can call at any time to insert the name into text within my webpages.

Any ideas?

Mile-O-Phile 11-30-2004 02:49 PM

Quote:

Originally Posted by Mile-O-Phile
I've stripped my version of this code to:

Code:

<?php

// GO TO FORUM DIR
chdir('./forum');

// STANDARD VBULLETIN STUFF
define('NO_REGISTER_GLOBALS', 1);
//define('THIS_SCRIPT', 'script_name');
require_once('./global.php');

// GENERIC_SHELL VARS
$pagetitle = "Talk History Test";
$HTML = ""; // PIECED TOGETHER IN SCRIPT

eval('$HTML = "' . $bbuserinfo[username] . '";');
eval('print_output("' . $bbuserinfo[username]. '");');
?>

This is because I only want to get the username from the forum to display on an independent web page. However, it keeps on creating a new HTML page with the user's name. So, I'd like to be able to convert it into a function (called get_form_user() ) that I can call at any time to insert the name into text within my webpages.

Any ideas?

*BUMP* :(

Andreas 11-30-2004 02:58 PM

If you just want the username you don't need to load the whole vB backend.
Just check the cookies (bbuserid, bbpassword) and query table user


All times are GMT. The time now is 04:46 PM.

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.02471 seconds
  • Memory Usage 1,946KB
  • 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
  • (5)bbcode_code_printable
  • (16)bbcode_php_printable
  • (9)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete