vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Create your own vBulletin page (https://vborg.vbsupport.ru/showthread.php?t=228112)

Shamil. 12-19-2010 11:24 AM

Quote:

Originally Posted by stevectaylor (Post 2136287)
Thanks lynne, I did guess that, but when inserted to the php it appears at the very top. How do you position a php include statement.

This is what I did

PHP Code:

<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''MANAGE');
define('CSRF_PROTECTION'true);  
// 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('manage_index',
);

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

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
 
chdir ('/home/hostcule/public_html');
require_once(
'./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (!in_array($vbulletin->userinfo['usergroupid'], array(5,6,7))) print_no_permission();

$navbits construct_navbits(array('' => 'Hosting Manager'));
$navbar render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'Hostcule Manager';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('manage_index');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?>

It went in after: Start Main Script.

stevectaylor 12-19-2010 04:39 PM

Quote:

Originally Posted by ct2k7 (Post 2136322)
This is what I did

PHP Code:

<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''MANAGE');
define('CSRF_PROTECTION'true);  
// 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('manage_index',
);

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

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
 
chdir ('/home/hostcule/public_html');
require_once(
'./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
if (!in_array($vbulletin->userinfo['usergroupid'], array(5,6,7))) print_no_permission();

$navbits construct_navbits(array('' => 'Hosting Manager'));
$navbar render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'Hostcule Manager';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('manage_index');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?>

It went in after: Start Main Script.

Thanks but can't really see how it changed.

Lynne 12-19-2010 04:45 PM

Quote:

Originally Posted by stevectaylor (Post 2136287)
Thanks lynne, I did guess that, but when inserted to the php it appears at the very top. How do you position a php include statement.

In the php page, test.php, after you include global.php, just include your script also - something like:
PHP Code:

chdir ('/home/hostcule/public_html');
require_once(
'./global.php');
include(
"offers/choice_ad1.php"); 

It should not have any output. If it does, then you need to assign it to a variable and then output that variable in your template where you want it.

stevectaylor 12-19-2010 04:56 PM

Quote:

Originally Posted by Lynne (Post 2136414)
In the php page, test.php, after you include global.php, just include your script also - something like:
PHP Code:

chdir ('/home/hostcule/public_html');
require_once(
'./global.php');
include(
"offers/choice_ad1.php"); 

It should not have any output. If it does, then you need to assign it to a variable and then output that variable in your template where you want it.

I had done this and seperately set a variable but both print the output before that header of the page.

Lynne 12-19-2010 05:28 PM

Quote:

Originally Posted by stevectaylor (Post 2136287)
Thanks lynne, I did guess that, but when inserted to the php it appears at the very top. How do you position a php include statement.

Quote:

Originally Posted by stevectaylor (Post 2136428)
I had done this and seperately set a variable but both print the output before that header of the page.

You need to look at the contents of that file. If it has any echo statements, then that is going to cause what you are seeing. You cannot use echo if you want to put the ads where you want them.

stevectaylor 12-19-2010 06:20 PM

I think I might have suused the issue. When I put in custom variables it doesn't like them e.g

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'My Page Title';
$pagead = 'trial';

Then in template add

{vb:raw pagead}

Nothing shows, but alter the standards and the standards work fine.

Lynne 12-19-2010 06:38 PM

Quote:

Originally Posted by stevectaylor (Post 2136469)
I think I might have suused the issue. When I put in custom variables it doesn't like them e.g

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'My Page Title';
$pagead = 'trial';

Then in template add

{vb:raw pagead}

Nothing shows, but alter the standards and the standards work fine.

You need to register any variable for use in a template.

stevectaylor 12-20-2010 08:57 AM

Quote:

Originally Posted by Lynne (Post 2136452)
You need to look at the contents of that file. If it has any echo statements, then that is going to cause what you are seeing. You cannot use echo if you want to put the ads where you want them.

Registered the variable. What are the acceptable alternatives to echo as the print function also returns the same result?

Lynne 12-20-2010 03:14 PM

Quote:

Originally Posted by stevectaylor (Post 2136754)
Registered the variable. What are the acceptable alternatives to echo as the print function also returns the same result?

instead of:
PHP Code:

echo "Hello World!"

use
PHP Code:

$outputvar .= "Hello World!"


stevectaylor 12-20-2010 03:28 PM

Quote:

Originally Posted by Lynne (Post 2136853)
instead of:
PHP Code:

echo "Hello World!"

use
PHP Code:

$outputvar .= "Hello World!"


Thanks Lynne,

I found the answer in another thread of yours on vbulletin.com and used the following which works a dream.

PHP Code:

ob_start();
  include(
'offers/accommodation.php');
  
$pagead ob_get_contents();
  
ob_end_clean(); 


MatiasCandy 12-29-2010 02:25 AM

Lynne,

First Thank you for helping everyone.

My issue is a little more complexed

I understand how to add a page and I completed it pretty quick (just your test page)

Now that I have learned that what I need to do is get a bit more complex.

I have a custom app I am trying to bring into vb4.x. Someone else had it in 3.8 but it was very sloppy and I want it to be perfect.

So here are the first set of questions:

1. how do I add conditions in the template for

if guest show this "please register"
if Registered but never filled out app show this "Please Fill this out"
If registered and filled this out show "Welcome Back."

now all of this is already in PHP in my file but I want this app to be perfect like I said.

2. In my PHP file they have html / php mixed mainly queries of the database, display results, and $bbuserinfo[useremail], etc...

Please go slow I am not a programmer but I want to learn how to do this.

Thank you for your time

Lynne 12-29-2010 02:40 AM

This is an article about how to create another page. For your questions....
1. Read the other articles in this forum about conditions. If you have questions, post them in that article. If you can't get your page to work, you need to post your own thread with the complete code for your page and templates.

2. Not sure what your question is there as it's just a statement.

MatiasCandy 12-29-2010 03:29 AM

Thank Lynne, I have started my own thread over here (in case you still want to help me)

My First Import

larryd 12-29-2010 12:09 PM

Can you tell me what I'm doing wrong here? This script should be returning and printing out the id field from all entries in the database yet it only returns and prints the last id.

http://vb.newcelica.org/test.php

Code:

$navbits = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);

$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);

// ###### YOUR CUSTOM CODE GOES HERE #####

include(config.php);
$result = mysql_query("SELECT * FROM dynotable WHERE name <> '' ORDER BY name ASC",$dynodb);

while ($row = mysql_fetch_array($result)) {
$id = $row["id"];

$output = "<table><tr><td>id</td><td>$id</td></tr></table>";

$templater->register('output', $output);
print_output($templater->render());

}

?>


Lynne 12-29-2010 04:03 PM

Quote:

Originally Posted by larryd (Post 2140661)
Can you tell me what I'm doing wrong here? This script should be returning and printing out the id field from all entries in the database yet it only returns and prints the last id.

http://vb.newcelica.org/test.php

Code:

$navbits = construct_navbits(array('' => 'Test Page'));
$navbar = render_navbar_template($navbits);

$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);

// ###### YOUR CUSTOM CODE GOES HERE #####

include(config.php);
$result = mysql_query("SELECT * FROM dynotable WHERE name <> '' ORDER BY name ASC",$dynodb);

while ($row = mysql_fetch_array($result)) {
$id = $row["id"];

$output = "<table><tr><td>id</td><td>$id</td></tr></table>";

$templater->register('output', $output);
print_output($templater->render());

}

?>


Once you use print_output, that is the end of the page rendering. You only use print_output when you are completely done and ready to render the page.

stevectaylor 01-03-2011 06:30 PM

Any ideas how to get the like button to show on the page?

Lynne 01-03-2011 11:52 PM

Quote:

Originally Posted by stevectaylor (Post 2143478)
Any ideas how to get the like button to show on the page?

You would just add the code to the template. I do not know the exact code, if that is what you are asking.

gaitantkd 01-07-2011 03:28 PM

hi i tried this but no luck using vb 4.1.0 PL2

test.php
PHP Code:

<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''test');
define('CSRF_PROTECTION'true);  
// 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('TEST',
);

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

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

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

$navbits construct_navbits(array('' => 'Test Page'));
$navbar render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'My Page Title';

// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?>

template named test:
HTML Code:

{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle}</title>
    {vb:raw headinclude}
  </head>
  <body>
   
    {vb:raw header}
   
    {vb:raw navbar}
   
    <div id="pagetitle">
      <h1>{vb:raw pagetitle}</h1>
    </div>
   
    <h2 class="blockhead">Title</h2>
    <div class="blockbody">
      <div class="blockrow">
        Text
      </div>
    </div>
   
    {vb:raw footer}
  </body>
</html>


Lynne 01-07-2011 03:57 PM

Quote:

Originally Posted by gaitantkd (Post 2145473)
hi i tried this but no luck using vb 4.1.0 PL2

test.php
PHP Code:

.......
// pre-cache templates used by all actions
$globaltemplates = array('TEST',
);

.......

$templater vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?> 

template named test:

You clearly state in your php page that your template is named "TEST" and then you named your template "test". That is not the same. You need to name it "TEST" (ALL CAPS).

cindie 01-13-2011 09:36 PM

The page is working fine, but when it displays the new (Gallery) page, the Forum tab is up instead of the new (Gallery) tab and the submenu for Forum is showing. Any ideas?

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

Never Mind.

rumas 01-14-2011 05:26 PM

Hello Lynne,
I used this thread to create a Google custom search results page and it works great.

However, my problem is I have Google adsense ads in the navbar and footer, how do I exclude the ads from the "search results page" as they are against Google terms of service?

Lynne 01-15-2011 03:37 AM

You would need to put a condition around the code in the ad to not show it on this page. (Use your definition of THIS__SCRIPT in the condition.)

rumas 01-16-2011 09:08 AM

Thank you Lynne for helping me and everyone else with in this thread...

Here is the condition I used around the ad, works great. Maybe this will help someone else!

Code:

<vb:if condition="THIS_SCRIPT != 'Your_Definition'">

</vb:if>


tonmo 01-16-2011 01:20 PM

Hi Lynne - I'm wondering if you can help me. I have tons of pre-existing custom HTML (actually .php) pages, all which leverage a server-side include, let's call it header.php.

I'd like to replace the contents of header.php with something that would allow all of my pre-existing pages to automagically support my vbulletin header and navigation.

All these pages also reference a footer.php, if that is helpful to the cause (but that's easy enough for me to replicate, at least visually what is shown to the user).

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

Quote:

Originally Posted by rumas (Post 2149908)
Thank you Lynne for helping me and everyone else with in this thread...

Here is the condition I used around the ad, works great. Maybe this will help someone else!

Code:

<vb:if condition="THIS_SCRIPT != 'Your_Definition'">

</vb:if>


I get an undefined error when trying to wrap this around my ad code via the Advertisements feature within AdminCP. Do you embed your ads manually?

Lynne 01-16-2011 05:10 PM

Sorry tonmo, but I don't understand your question at all. This is just a tutorial on how to make a single custom page. If you want to reference other scripts in the page, that is fine, but you need to write the code in those scripts and write the code in the php page. This isn't a tutorial on how to write your code.

As for the undefined error.... you need to change Your_Definition to a valid name or that isn't going to work.

tonmo 01-16-2011 05:36 PM

To clarify - I have dozens of static php pages that I created long before I implemented vBulletin. The page format is this:

HEADER
..
UNIQUE ARTICLE CONTENT
..
FOOTER

The HEADER and FOOTER are separate included files (i.e., header.php and footer.php); they are common across all article pages. I am wondering if there is any common vb4 code I can put into the header and footer files in order to wrap all of these articles into the vbulletin look and feel. I'm running 4.1.1.

Does that help explain what I'm trying to do?

Lynne 01-16-2011 06:27 PM

Quote:

Originally Posted by tonmo (Post 2150129)
To clarify - I have dozens of static php pages that I created long before I implemented vBulletin. The page format is this:

HEADER
..
UNIQUE ARTICLE CONTENT
..
FOOTER

The HEADER and FOOTER are separate included files (i.e., header.php and footer.php); they are common across all article pages. I am wondering if there is any common vb4 code I can put into the header and footer files in order to wrap all of these articles into the vbulletin look and feel. I'm running 4.1.1.

Does that help explain what I'm trying to do?

Yes, that explains it better. I would guess you would want to assign the contents of those files to a variable and then spit them out into the template. I know I've seen the code posted around here to do that, but don't know it off the top of my head. (I think it's even posted in this thread somewhere.)

TheInsaneManiac 01-17-2011 03:43 AM

Quote:

Originally Posted by Lynne (Post 2127372)
Basically the same except you need to change all your eval/fetch_template statements to use the new syntax (the new syntax is covered in other articles, although shown in the code for this one).

Can you use an example.

tonmo 01-17-2011 01:00 PM

Quote:

Originally Posted by Lynne (Post 2150162)
Yes, that explains it better. I would guess you would want to assign the contents of those files to a variable and then spit them out into the template. I know I've seen the code posted around here to do that, but don't know it off the top of my head. (I think it's even posted in this thread somewhere.)

Thanks - but probably not for me. I want each page to retain its own unique title and I don't believe your method would allow that.

All of my static pages exist in different places throughout my site, and have signifcant inbound links that I don't want to break. So far I've found two ways to convert them into vb pages:

1) Simply create new Article pages via CMS and copy/paste the original article contents into the new file. Convert the static page to a permanent redirect which points to the new CMS article.

2) Use the method described in this thread (How To Create Your Own vBulletin Page).

I'm finding both to be a bit labor-intensive (I have dozens of pages). Maybe 5 or 10 mins per article - those add up! Since all my static pages use server-side includes for the header and footer, I was hoping I could insert the logo, ad, and navbar at the top, and the footer at the bottom, so that I would only need to edit two files (the two includes) and viola! My site is converted. Seems that's not an option?

fireglow305 01-28-2011 01:59 PM

Good article, thank you. ;)

odln018 02-04-2011 04:59 PM

I must be truly dumb, as I can't get this to work. I don't know what to use as a "link.php". Also, should the drop down appear if the link.php doesn't exist?

Stupid I'm sure.

Lynne 02-04-2011 05:17 PM

Quote:

Originally Posted by odln018 (Post 2158764)
I must be truly dumb, as I can't get this to work. I don't know what to use as a "link.php". Also, should the drop down appear if the link.php doesn't exist?

Stupid I'm sure.

link.php? And what dropdown?

odln018 02-04-2011 05:18 PM

Geez, I can't even post in the right thread.

odln018 02-05-2011 07:15 PM

Would someone who's gotten this up and running please PM me?

Thanks in advance

ceho 02-12-2011 04:28 PM

Hi, would it be possible to add any information from a user's profile (Profile, Image Options, User Profile Fields) to a custom site? I have all the conditions etc., e.g. from postbit_legacy, but I don't get any of these to be displayed on a custom site. Or would I have to change the php file, or add something to the head of my custom site...? Sorry, I am lost, would be great to get a hint here. Thanks in advance.

Lynne 02-12-2011 04:30 PM

Quote:

Originally Posted by ceho (Post 2161809)
Hi, would it be possible to add any information from a user's profile (Profile, Image Options, User Profile Fields) to a custom site? I have all the conditions etc., e.g. from postbit_legacy, but I don't get any of these to be displayed on a custom site. Or would I have to change the php file, or add something to the head of my custom site...? Sorry, I am lost, would be great to get a hint here. Thanks in advance.

You may put anything you want on this page. However, you may need to copy the php from another page onto this one if you want some of the same information displayed. You cannot just take a variable name that is used on another page and plop it into the template for this page and have it display the same thing. Behind every variable is some code that defines it.

ceho 02-12-2011 05:15 PM

Phew, this means I need to find out which php is behind each condition? Would you know a trick to do so? Firebug doesn't help on this I am afraid. Let's say I want to copy the content from postbit_legacy to a custom site, how can I find out the correct php file? Can I just copy the content into the according php content of my custom page?

Just a little hint and I try my best to go on alone ;-). Thanks a lot for you quick help Lynne!

basilrath 02-13-2011 09:11 PM

Is it possible to get the "whos viewing this thread or post" box at the bottom of my custom page?

Lynne 02-13-2011 11:39 PM

Quote:

Originally Posted by basilrath (Post 2162293)
Is it possible to get the "whos viewing this thread or post" box at the bottom of my custom page?

Sure, if you copy the code for it also.

iBaker 02-14-2011 06:24 AM

I have found with 4.1.1 that:
- If I have the forums in my root
- My pages in a folder /pages/
- I use the chdir ('/home/xxxx/public_html');

The page displays with correct styling ONLY if I have the vb option "Always use Forum URL as Base Path" set to Yes...If I set it to No (which I need to do) I lose all the styling from the vb style

Anyone come across this and know of a way around it?


All times are GMT. The time now is 12: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.02892 seconds
  • Memory Usage 1,918KB
  • 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
  • (4)bbcode_code_printable
  • (1)bbcode_html_printable
  • (11)bbcode_php_printable
  • (20)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