vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   How to create your own vBulletin-powered page! (uses vB templates) (https://vborg.vbsupport.ru/showthread.php?t=62164)

Digital Jedi 07-04-2008 06:51 PM

Works fine with with 3.7.1, and the only difference there is some bug/security fixes.

TheInsaneManiac 07-05-2008 05:04 AM

So I don't end up making like 10 pages, is there a way I can do like the misc.php page and be like test.php?do=mypage

I wish to make a custom page, but also have links that go to a different subpage within the same link.

pooker 07-05-2008 12:59 PM

I have a php script I need to run could someone please tell me how I can use it with this article, seeing as with templates it can only call variables from php it seems.

Please I really need help with this thanks

TheInsaneManiac 07-05-2008 04:10 PM

Quote:

Originally Posted by pooker (Post 1567341)
I have a php script I need to run could someone please tell me how I can use it with this article, seeing as with templates it can only call variables from php it seems.

Please I really need help with this thanks

Yea I have a similar issue, I can't get javascript to run lol.

Cip 07-06-2008 02:08 AM

Alot of people seem to have troubles prohibiting guests from accessing their custom pages, I've seen a couple of different methods but none of which seem to work.

Here's what I did, and it works just fine:
Code:

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

$navbits = array();
$navbits[$parent] = 'Manage Account';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
// ######################## START CIP EDITION #############

if ($vbulletin->userinfo['userid'] == 0)
{
        $show['permission_error'] = 1;
        eval('print_output("' . fetch_template('STANDARD_ERROR') . '");');
}
elseif (isset($_REQUEST['do']))
{
//And my code goes on, but that's none of your business *evil grin*
eval('print_output("' . fetch_template('YourTemplateWhateverItIsNamed') . '");');
}


TheInsaneManiac 07-06-2008 11:25 PM

For some reason this has issues with my submit button. It is suppose to convert text to hex, but instead it refreshes. Any idea?

Code:

<input id="box" value="YourHexCodeHere" maxlength="48" size="90" name="text" type="text"><input onclick="runHex(document.text2hex.text.value);return false" generate="" value="Convert" type="submit">

Cip 07-07-2008 12:07 AM

^ This has nothing to do with the article, but to solve your problem I think all you need to do is change the "type" attribute from "submit" into "button"

DieselMinded 07-07-2008 05:50 PM

Something ive done with this mod

http://www.dieselbombers.com/About.php

Goomzee 07-08-2008 06:44 AM

Quote:

Originally Posted by DiesellMinded (Post 1569321)
Something ive done with this mod

http://www.dieselbombers.com/About.php

yes exactly like this page i want to make but for everyone guest and members both can access this code could you plz make me that kind of code for my this page

http://www.mknexusonline.com/test.php

DieselMinded 07-08-2008 08:55 AM

Mine does show to guests and members , hints the Register Link on the page

Its HTML dropped in to a VB powered page that this mod creates , Your test page does not have this mod on it , you have to make a vb powered page then on the template insert html code to get what you want .

Land a version of Front Page 2003 , Open a new page and click design and knock your self out then switch to code and copy everything between the Body tags and put in your vb template and your done

Goomzee 07-10-2008 03:28 AM

how to make mod could to made and pm me that mod Please

DieselMinded 07-10-2008 07:55 AM

There is no mod here , its just html

Design the page in html and use this article to build a vb powered page and paste the html code in the new template

Zaxuhe 07-20-2008 01:32 AM

Thanks my page is finally using the vbulletin login systen due to this =D thanks a lot, members areas working anyone that need help fell free to send me a private message I wont probably reply on here

Mikhal 07-22-2008 12:42 PM

Using this method, is there anyway I can pass the content of the page into the template from the script? Essentially, I'm wondering if I can replace the value "Text" with something that is generated by the php script. Any hints would be appreciated.

Sergio68 07-22-2008 10:07 PM

Quote:

Originally Posted by amcd (Post 1540325)
Templates are not supposed to execute code. This is not just with vbulletin, but the entire concept of templating is separation of presentation from code (business logic).

Execute the php before calling the template, keep the presentation data in certain variables, and use the template just to show those variables.

Quite clear, can you please make an example ?

Suppose I have some pages I need to execute and show : page1.php, page2.php, page3.php
I should create some templates : template1, template2, template3
Then insert the variables : $show1 (containing the html execution of page1.php) into template1, $show2 (containing the html execution of page2.php) into template2 and so on.

But how can I generate/fill (for example) the variables and insert them into the template when I link the user to mysite.com/forums/page2.php ?

--------------- Added [DATE]1216770050[/DATE] at [TIME]1216770050[/TIME] ---------------

Found, may be, I should add a plugin :

Code:

ob_start();
  include('./page2.php');
  $show2 = ob_get_contents();
  ob_end_clean();


Is it ?

Chris11987 07-23-2008 06:46 AM

Is there a way to do this outside of the forums directory?

Sergio68 07-23-2008 09:03 AM

Quote:

Originally Posted by Sergio68 (Post 1581826)
Quite clear, can you please make an example ?

Suppose I have some pages I need to execute and show : page1.php, page2.php, page3.php
I should create some templates : template1, template2, template3
Then insert the variables : $show1 (containing the html execution of page1.php) into template1, $show2 (containing the html execution of page2.php) into template2 and so on.

But how can I generate/fill (for example) the variables and insert them into the template when I link the user to mysite.com/forums/page2.php ?

--------------- Added [DATE]1216770050[/DATE] at [TIME]1216770050[/TIME] ---------------

Found, may be, I should add a plugin :

Code:

ob_start();
  include('./page2.php');
  $show2 = ob_get_contents();
  ob_end_clean();


Is it ?

And.... what about a change in my page1.php :

PHP Code:

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

with
PHP Code:

Direct execution of template+php code 

It's most probably not safe, but, is it working ?

--------------- Added [DATE]1216816873[/DATE] at [TIME]1216816873[/TIME] ---------------

Ok, I apologize for all this asking and answering by myself :D , I've tried and it's working.
Can be a big shortcut, no templates, no plugins, but it's obviously less safe.

amcd 07-23-2008 05:48 PM

Quote:

Originally Posted by Sergio68 (Post 1582122)
Can be a big shortcut, no templates, no plugins, but it's obviously less safe.

Then it is not really a vb-powered page, is it?

Sergio68 07-24-2008 10:25 AM

Quote:

Originally Posted by amcd (Post 1582438)
Then it is not really a vb-powered page, is it?

LOL :D May be, right. That's what I'm trying to figure it out, I'll be still able to use VB variables, IFs and so on or should I just please myself with the look and style of the forum ?

Stryker412 07-24-2008 04:44 PM

How can you get your page to auto adapt to the current theme a user is running (ie. font and panel colors)?

Sergio68 07-24-2008 06:04 PM

Quote:

Originally Posted by Stryker412 (Post 1583225)
How can you get your page to auto adapt to the current theme a user is running (ie. font and panel colors)?

Be careful, this is not the correct and safe way to do it, but if you build your test.php page like this :

PHP Code:

<?php

error_reporting
(E_ALL & ~E_NOTICE); 
define('NO_REGISTER_GLOBALS'1); 
define('GET_EDIT_TEMPLATES'true); 
define('THIS_SCRIPT''releases'); 
$phrasegroups = array(); 
$specialtemplates = array(); 
$globaltemplates = array(); 
$actiontemplates = array(); 
// require_once('./includes/vba_cmps_include_template.php');
// chdir('/srv/www/www.bodyweb.it/forums/');
 
require_once('./global.php'); 
// $vbulletin->options['homeurl'];
        
$navbits = array(); 
        
$navbits[''] = 'Prodotti'
        
$navbits construct_navbits($navbits); 
        eval(
'$navbar = "' fetch_template('navbar') . '";'); 
      
//  eval('print_output("' . fetch_template('prodotti') . '");'); 

     // **** include code
    //  **** Template HTML echo instead of   eval template and plugin ****

      
echo"
      
$stylevar[htmldoctype]
<html dir='
$stylevar[textdirection]' lang='$stylevar[languagecode]'>
<head>
<title>
$vboptions[bbtitle] -  Prodotti</title>
$headinclude
<script type='text/javascript' src='./forums/clientscript/vbulletin_global.js'></script>
<script type='text/javascript' src='./forums/clientscript/vbulletin_menu.js '></script>
</head>
$header
$navbar


//  **** more code.


$footer
</body>
</html>"
;
      
      
       
      
?>

You just need one page, you can also include part of header template and footer template

Digital Jedi 07-24-2008 10:49 PM

Quote:

Originally Posted by Sergio68 (Post 1583275)
Be careful, this is not the correct and safe way to do it, but if you build your test.php page like this :

PHP Code:

<?php

error_reporting
(E_ALL & ~E_NOTICE); 
define('NO_REGISTER_GLOBALS'1); 
define('GET_EDIT_TEMPLATES'true); 
define('THIS_SCRIPT''releases'); 
$phrasegroups = array(); 
$specialtemplates = array(); 
$globaltemplates = array(); 
$actiontemplates = array(); 
// require_once('./includes/vba_cmps_include_template.php');
// chdir('/srv/www/www.bodyweb.it/forums/');
 
require_once('./global.php'); 
// $vbulletin->options['homeurl'];
        
$navbits = array(); 
        
$navbits[''] = 'Prodotti'
        
$navbits construct_navbits($navbits); 
        eval(
'$navbar = "' fetch_template('navbar') . '";'); 
      
//  eval('print_output("' . fetch_template('prodotti') . '");'); 

     // **** include code
    //  **** Template HTML echo instead of   eval template and plugin ****

      
echo"
      
$stylevar[htmldoctype]
<html dir='
$stylevar[textdirection]' lang='$stylevar[languagecode]'>
<head>
<title>
$vboptions[bbtitle] -  Prodotti</title>
$headinclude
<script type='text/javascript' src='./forums/clientscript/vbulletin_global.js'></script>
<script type='text/javascript' src='./forums/clientscript/vbulletin_menu.js '></script>
</head>
$header
$navbar


//  **** more code.


$footer
</body>
</html>"
;
      
      
       
      
?>

You just need one page, you can also include part of header template and footer template

All you really need to do is make a template for each respective style on your forum, using this same tutorial.

Sergio68 07-25-2008 02:16 PM

Quote:

Originally Posted by Digital Jedi (Post 1583452)
All you really need to do is make a template for each respective style on your forum, using this same tutorial.

Ok, and how to include and execute PHP code into the template?

Digital Jedi 07-25-2008 04:17 PM

No idea. I'm just responding the to the question about how to have a users style show up on that page. In fact, if you have multiple styles, you have to make a template for each style, otherwise you get a blank page.

amcd 07-26-2008 06:57 AM

If you have multiple styles, ideally they should be in a heirarchy. Just add the template to the top level and it will be inherited by child styles.

The question of how to execute php from templates is being asked frequently. The answer is that you cannot. It is not supposed to be that way. The primary objective of templating is to separate logic (php) from presentation (templates).

Search for my posts in this thread. I have explained the whole thing with code examples.

Sergio68 07-26-2008 11:57 AM

Quote:

Originally Posted by amcd (Post 1584461)
If you have multiple styles, ideally they should be in a heirarchy. Just add the template to the top level and it will be inherited by child styles.

The question of how to execute php from templates is being asked frequently. The answer is that you cannot. It is not supposed to be that way. The primary objective of templating is to separate logic (php) from presentation (templates).

Search for my posts in this thread. I have explained the whole thing with code examples.

I knew, it was a rhetorical question, this is why I was looking for shortcuts.
By the way, you can execute code in a plugin but it's a p.i.t.a.

Goomzee 07-27-2008 06:54 AM

this is my php file code

Quote:

<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'mk1'); // 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(
'MK1',
);

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

);

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

chdir('/home/username/public_html/content/mkgames/mk1/');
require_once('./global.php');


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

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

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

?>
__________________
a

and this my Template Code

Quote:

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

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat"><center>Mortal Kombat Shaolin Monks Play Station2 Guide</center>
</td>
</tr>
</table>
<p><strong>Unlock Mortal Kombat II</strong><br>

$footer
</body>
</html>
Templaet Naem is MK1

but nothing working since 4 month

amcd 07-27-2008 07:06 AM

Code:

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

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

change this to

Code:

$navbits = array();
$navbits[$parent] = 'Mortal Combat blah blah';

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


Goomzee 07-28-2008 03:31 AM

i did but not working

Digital Jedi 07-28-2008 04:37 AM

Quote:

Originally Posted by Goomzee (Post 1585085)
this is my php file code




and this my Template Code



Templaet Naem is MK1

but nothing working since 4 month

PHP Code:

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

You never changed TEST on this line to your template name.

amcd 07-28-2008 05:02 AM

Quote:

Originally Posted by Digital Jedi (Post 1585687)
PHP Code:

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

You never changed TEST on this line to your template name.

What's what I told him, too. But he said it doesn't work.

Digital Jedi 07-28-2008 05:11 AM

Quote:

Originally Posted by amcd (Post 1585698)
What's what I told him, too. But he said it doesn't work.

Yes, but for some reason you also told him to change

PHP Code:

$navbits[$parent] = 'MK1'

to
PHP Code:

 $navbits[$parent] = 'Mortal Combat blah blah'

Which is likely why it didn't work.

Quote:

Originally Posted by amcd (Post 1585091)
Code:

$navbits = array();
$navbits[$parent] = 'MK1';
 
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('TEST') . '");');

change this to

Code:

$navbits = array();
$navbits[$parent] = 'Mortal Combat blah blah';
 
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('MK1') . '");');



Goomzee 07-28-2008 12:16 PM

i don;t understand why it's not working where as file is still there

Digital Jedi 07-28-2008 01:14 PM

In chdir('/home/username/public_html/content/mkgames/mk1/');, did you actually put in your username, or did you just leave it like this?

amcd 07-28-2008 05:27 PM

Quote:

Originally Posted by Goomzee (Post 1585913)
i don;t understand why it's not working where as file is still there

A completely blank page usually means php error. See the php error log.

Keesa 07-29-2008 04:40 AM

Hi there,

Do you know how I could edit this template or .php file so that the Notices do not show up if they are active?

Thank you so much for your help!

stevectaylor 07-29-2008 09:48 AM

I Like it, do you know how to add the tag box too it?

mauriceo 07-29-2008 07:54 PM

It must be me but i don't know in wich directory i have to put the template file. Ive uploaded the test.php in the root directory of vbulletin but i can't find a folder with templates to put the test.tpl in. Can anybody tell me what i'm doing wrong?

edit: I've found the way to add templates but when i go to the test.php i've a blanc page.
Quote:

Originally Posted by amcd (Post 1586113)
A completely blank page usually means php error. See the php error log.

Where can i find this error logs... i know i'm a beginner.

Digital Jedi 07-30-2008 12:44 AM

Quote:

Originally Posted by mauriceo (Post 1586902)
It must be me but i don't know in wich directory i have to put the template file. Ive uploaded the test.php in the root directory of vbulletin but i can't find a folder with templates to put the test.tpl in. Can anybody tell me what i'm doing wrong?

edit: I've found the way to add templates but when i go to the test.php i've a blanc page.
Where can i find this error logs... i know i'm a beginner.

Templates are created in the Admin CP in the Style Manager, they're not part of any directory. Make sure the template name is exactly the same as where it's referred to in the PHP code.

mauriceo 07-30-2008 03:04 AM

I've copied unchanged the exact text from the first post (test.php and the template test)


All times are GMT. The time now is 05:50 AM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02795 seconds
  • Memory Usage 1,889KB
  • 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
  • (8)bbcode_code_printable
  • (8)bbcode_php_printable
  • (19)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (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