![]() |
Some basics of vB3(mini howto)
Some basics of vB3(mini howto)
also some basic php junk the most important thing if you want to make pages based on templates or anything of the such would be to first know how to " connect" to vbulletin, and then learn how to call and eval templates. so lets take a look at the most BASIC page we can do PHP Code:
somthing abit more advanced. suchas calling more than one template, or doing an action it becomes abit more complicated PHP Code:
PHP Code:
if your going to write a script that is ALL actions you should add somthing like this right after the call to gobal.php PHP Code:
Mini Tut by Faranth (with some help from Brad.loo fixing my silly newbie mistakes :) ) |
...Nice....good for n00bs like me :)
|
Quality work there Faranth. DEFINITELY a good resource for those wanting to make a custom page but don't know where to start! This might inspire me to chime in myself and write up a few mini tutorials. Keep up the good work bro! Cheers!
Regards, Patrick |
Quote:
|
Yeah, nice job. ^^ :)
|
Just a little note, if you are going to be writing scripts that are a bit more advanced. Sometimes you will need to retrive information from vBulletin datastore templates, to do so add this above the call to global.php
PHP Code:
|
Quote:
|
Handy // Confusing tips there :) Thanks
|
confusing?
|
If you want too be ;)
|
[high]* Faranth is now confused :([/high]
|
Yup that was my main aim :) Lol, nah i meant at first that it was confusing because i was reading too fast, and still scratching up on the ol' PHP
|
Quote:
:) hope it helped |
Quote:
|
Quote:
|
Hi, I notcied one error with the action templates call. It should be:
PHP Code:
|
whatchu talkin about foo :P
|
|
Faranth, any hint:
I copied the first code block (the very easy one :-) ) and tried it: Nothing gets displayed. Any hint? |
I created a new, empty file. This is all and exactly what's in there:
PHP Code:
If I open http://www.mydomain.com in a browser, this is what I receive: HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> For troubleshooting I replaced the print_output with: echo fetch_template('main'); and received an empty string, too. Please help. |
@Faranth:
Additionally, you say that $globaltemplates = array('main'); is for caching templates? How does this work? To me it appears as if you just declare a local array? The fetch_template function in functions.php does not reference any var named $globaltemplates. Could you possibly explain why you init this array in the page? And I'm still not getting the template :-( THANKS FOR BEING PATIENT WITH ME! :-) |
Some more troubleshooting steps it now appears as if the fetch_template does not return any content. It's empty... hmm... HELP!
|
Quote:
yes $globaltemplates cach's the template do you HAVE a template called main in the database? |
Faranth, my capitalized "help" was in no way ment to offend you in any way. It's just I was in such a despair...
Do I have a template called "main"... honestly, I don't know. Maybe. Is there any standard template, comming with the clean default vB3 RC2 install I could test instead? And: I understood that you were saying that the $globaltemplates array is done to cache templates but I don't know how it does so. Is there a GLOBAL variable named $globaltemplates in the vB system? I mean, if I put this statement at the top of my script, all it does is create an array with a single string value but how does this "instruct" vb to cache a template? |
lol thats most lily your problem you dont have another tempalte atm lol ^^
make a new template called main and add anything you like to it :) |
And one more question, Faranth (sorry, knowing that you're online is just too attractive.. :-) ):
Why do I have to use eval(...). Couldn't I just do a $output = fetch_template(...); echo $output; ? |
why two lines?
eval('print_output("' . fetch_template('main') . '");'); one simple line, plus this is how its done for all files in vb |
Hmm. I see. I might not have asked my question the right way. (I'm not a native English speaker. Sorry again.)
I was wondering why to use the eval() at all? Why not: echo fetch_template("FORUMHOME"); but instead: eval('echo "'.fetch_template(...).'");'); So my main question was: Why do we use eval here? Is it, because templates might contain php code, too? or vars? (Btw.: You were right with the "main" template. If I replace it with e.g. FORUMHOME, it works great.) I still do not understand how the declaration of the local variable $globaltemplates helps caching... |
ah yes, actually , if conditions are inlaid php :) all of the tempaltes are stored in php format to boot
|
If I slap your (longer) example into a blank .php page and use the shell_blank as my template (unchanged); I get an "object expected" error when the page tries to run this script:
Code:
<script type="text/javascript"> PHP Code:
|
Quote:
|
Code:
<script type="text/javascript"> I put this in my forums directory and it was error-free. However - despite the nav (with the user cp/register, faqs, etc.) being included in the shell, I still don't see that. Am I missing some other include? |
If your not using Gamma you should prefix all the JS includes with $vboptions[bburl]/ to make sure they get included properly if you have pages outside of the forums directory.
|
doh! i knew i forgot about sumthing, thanks NTLDR :)
|
Surely, easy fix... but how do I get that main/top nav into my page?
|
Quote:
eval('$front_header = "' . fetch_template('header') . '";'); |
Isn't that already called by shell_blank though?
Code:
$stylevar[htmldoctype] |
To follow up my own question, I needed this within my code:
Code:
eval('$navbar = "' . fetch_template('navbar') . '";'); However - links, etc. were all wrong since the navbar template isn't pathed correctly (would need to add $vboptions[bburl]/ in many places I'm assuming). Just thought I'd update. |
yeap you would
|
Is it hard to set permissions for a page, if not, how would I do that?
I want to restrict usergroups to this page. |
All times are GMT. The time now is 07:09 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 | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|