PDA

View Full Version : Pulling Templates


Osterling
07-31-2007, 08:56 PM
I am developing a File Sharing system, which after it's done, I would like to release it here. I have only one problem, vbulletin template based system. I need a way to retrieve the header, headinclude, and footer. I started doing it my way, which was this.

I'd search the table user for the persons username, and then check out what their default style was. After that, I did a search in the table template with the conditions being styleid, and searching for the specific template I wanted (eg navbar). Once I did that, I saw that I would need to search the phrase table in order to replace things like, $vbphrase[members_list].

I think I could eventually get it to work right, but I think it would be a heck of a lot of code, and querying. I'm hoping someone could show me a easier way in retrieving templates. So if someone wouldn't mind taking me under the wing, I'd really appreciate it.

p.s. I'll give recognition to who ever helps me when I release the File Sharing system

Thank you,
Osterling.

Opserty
07-31-2007, 09:14 PM
I'm still a bit of a coding rookie but using:


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


Should automatically select the template from the users selected style and replace the phrases if you have set them in the templates.

Source: https://vborg.vbsupport.ru/showthread.php?t=98009

Osterling
07-31-2007, 09:56 PM
Thank you, that got line of code got me a bit further but still having problems. It displays the header, but it doesn't display the navbar or footer. It is almost like it stops loading after that line.


<?php
/* vBulletin Information Retrieval*/
$curdir = getcwd ();
chdir('/home/shhh/public_html/');
require_once('/home/shhh/public_html/global.php5');
chdir ($curdir);

/* Name and User Id of User*/
$user_id = $vbulletin->userinfo['userid'];
$user_name = $vbulletin->userinfo['username'];

/*Find out what style a user has selected and retrieve the CSS for that style */
$user_sql = "SELECT * FROM user WHERE username = '$user_name'";
$execute_user_sql = mysql_query($user_sql);
$number_of_retrievals = mysql_num_rows($execute_user_sql);

if($number_of_retrievals == "1"){
$user_information = mysql_fetch_array($execute_user_sql);
$style_id = $user_information[styleid];

if($style_id == "0" || $style_id == "1"){
$style_sql = "SELECT * FROM style WHERE styleid = '1'";
$execute_style_sql = mysql_query($style_sql);
$style_information = mysql_fetch_array($execute_style_sql);
$style_css = $style_information[css];
echo $style_css;
}
else{
$style_sql = "SELECT * FROM style WHERE styleid = '$style_id'";
$execute_style_sql = mysql_query($style_sql);
$style_information = mysql_fetch_array($execute_style_sql);
$style_css = $style_information[css];
echo $style_css;
}
}
else{
$style_sql = "SELECT * FROM style WHERE styleid = '1'";
$execute_style_sql = mysql_query($style_sql);
$style_information = mysql_fetch_array($execute_style_sql);
$style_css = $style_information[css];
echo $style_css;
}

echo eval('print_output("' . fetch_template('header') . '");');

echo eval('print_output("' . fetch_template('navbar') . '");');

echo eval('print_output("' . fetch_template('footer') . '");');
?>

Opserty
07-31-2007, 10:08 PM
Look at the source link I provided in the first post. If you follow it through it should show you how to use templates to create custom vBulletin pages.

Osterling
07-31-2007, 10:17 PM
I did check it out. Though the page I am creating, I don't want to call it from the template system, instead call it from a flat file using PHP. So I want to display the Header, Navbar, then have it load my file, followed by the footer.

For some reason, it just stops loading after

echo eval('print_output("' . fetch_template('header') . '");');

When I swap it with footer, or navbar, it will display. For some reason it just stops loading after the first eval() statement.

I did check it out. Though the page I am creating, I don't want to call it from the template system, instead call it from a flat file using PHP. So I want to display the Header, Navbar, then have it load my file, followed by the footer.

For some reason, it just stops loading after

echo eval('print_output("' . fetch_template('header') . '");');

When I swap it with footer, or navbar, it will display. For some reason it just stops loading after the first eval() statement.

Opserty
07-31-2007, 10:26 PM
Try to change the print_output to just print then as the print_output stops the execution. Also I don't think you need the echo function at the start.

Dismounted
08-01-2007, 06:11 AM
Take a look at the article about creating vBulletin-powered pages.

Adrian Schneider
08-01-2007, 06:32 AM
Here's your general problem:

eval('print_output("' . fetch_template('MAIN_TEMPLATE') . '");');Stops executing the script, and prints (evaluates) that template. So, before you call that, you'll need to set the other templates as variables like this: eval('$navbar = "' . fetch_template('navbar') . '";');Then $navbar will be available in your MAIN_TEMPLATE.

Prior to including global.php, be sure to populate an array of all the templates you plan to use and name it $globaltemplates, so vBulletin can cache them for you.

(Do read that tutorial)

utw-Mephisto
08-20-2007, 04:15 PM
I subscribe to this thread .. I am exactly in the same position and I have the exact same reason why I need header, footer etc.

Dismounted
08-21-2007, 12:55 PM
Did you read the replies to the thread?