vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Pulling Templates (https://vborg.vbsupport.ru/showthread.php?t=153925)

Osterling 07-31-2007 08:56 PM

Pulling Templates
 
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:

PHP Code:

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 Code:

<?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

PHP Code:

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

PHP Code:

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:

PHP Code:

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:
PHP Code:

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?


All times are GMT. The time now is 10:45 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.01504 seconds
  • Memory Usage 1,755KB
  • 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
  • (6)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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