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)

Lynne 10-07-2010 08:40 PM

A custom site? You mean in the template for this page? You can use {vb:raw bbuserinfo.username} in a template.

ceho 10-08-2010 07:30 AM

Yes, this was exactly it. Very easy ;-). Thanks a lot!

Duncan 10-18-2010 04:31 AM

My forum is forum.com. However, I want to make a page at forum.com/pages/default.php

How do I go about doing this? I tried a couple of changes but no success.

Wilfred1 10-18-2010 04:46 AM

Quote:

Originally Posted by Duncan (Post 2111186)
My forum is forum.com. However, I want to make a page at forum.com/pages/default.php

How do I go about doing this? I tried a couple of changes but no success.

Duncan
All my pages are in a folder called pages so here is one of mine as an example. It is a page called "About This Site" and what you need to be aware of is the line that starts with "chdir" as this is where you will need to insert your site details so it changes the directory to where your forums are.
Code:

<?php

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

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

define('THIS_SCRIPT', 'about');
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('About',
);

// 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/MYSITE/public_html');
require_once('./global.php');

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

$navbits = construct_navbits(array('' => 'About This Site'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'About This Site';

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

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

?>

Hope it helps

Duncan 10-18-2010 04:52 AM

Thank you so much!! I will work on this now. I really appreciate it.

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

My forums are located at forums.com however, I want the pages to be in forums.com/pages/ - however, when I change the location to home/ACCOUNT/public_html/pages it doesn't work.

I get this error:

Fatal error: require_once() [function.require]: Failed opening required './global.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ACCOUNT/public_html/PAGES/mypage.php

When I install on the forum root, however, without any modifications it works like a charm. How can I get it to work in this directory?

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

Nevermind, I got it to work. Thank you!

ubcforums 10-24-2010 04:55 PM

Hi, can I use $_GET from the test.php ?

cellarius 10-24-2010 07:10 PM

Of course. You can use any php code. But you should use the vB input cleaning mechanisms: https://vborg.vbsupport.ru/showthread.php?t=119372

Dusty Miller 10-29-2010 12:54 PM

I've got a custom page that shows a search form, it then posts the result back to the same page. This works well if nobody is logged in.

If logged in you get the error:
Quote:

Your submission could not be processed because a security token was missing
I've followed and used this template anyone got an ideas what I'm doing wrong?

Lynne 10-29-2010 01:38 PM

You forgot to put the securitytoken into the form. Do a Search in Templates to find it used in other forms and use that code.

Dusty Miller 10-29-2010 05:48 PM

I've coded the form within the php page, not the template. Should the form be coded within the template page instead?

Lynne 10-29-2010 10:40 PM

Quote:

Originally Posted by Dusty Miller (Post 2115755)
I've coded the form within the php page, not the template. Should the form be coded within the template page instead?

It doesn't matter how it's coded as long as you include the securitytoken into the form. Usually it's an input field of type hidden.

Lostboyfan 11-10-2010 07:37 PM

Thank you Lynne for showing me how to do this. Now I can make a cutom home page with using VB templates.

------added--------

i wanted to make a page out of my vbulletin forum root. I keep getting this error and I have been stuck ever since.

Fatal error: Call to undefined function construct_navbits()

Anyone can PM me too if they want more details

hihello 11-17-2010 05:12 AM

I tried as instructed. Everytime I click on the the new navigation, it takes me to the new page but the tab jumps over to the forum nav. What am I doing wrong?

Lynne 11-17-2010 01:53 PM

Quote:

Originally Posted by hihello (Post 2122698)
I tried as instructed. Everytime I click on the the new navigation, it takes me to the new page but the tab jumps over to the forum nav. What am I doing wrong?

What new navigation? There is no navigation created in this page.

hihello 11-17-2010 03:58 PM

Quote:

Originally Posted by Lynne (Post 2122796)
What new navigation? There is no navigation created in this page.

I created a new navigation link to link to the new page. When I click the link, it goes to the page but highlights the forum link instead. I figured it may be the template problem since I tried two different ways and the outcome was the same. I tried adding my own script in navbar and then I tried the tab mod I found on this forum.

Lynne 11-17-2010 05:46 PM

Quote:

Originally Posted by hihello (Post 2122843)
I created a new navigation link to link to the new page. When I click the link, it goes to the page but highlights the forum link instead. I figured it may be the template problem since I tried two different ways and the outcome was the same. I tried adding my own script in navbar and then I tried the tab mod I found on this forum.

It would have to do with the condition you wrote for your new tab to show as active.

hihello 11-17-2010 09:42 PM

Yes. It's not the template. It's working now that I installed a new nav hack. It's very easy. Btw, I found your article on removing various navtab very help. I couldn't figure out how to remove the What's new. Thanks!!!

TheInsaneManiac 11-29-2010 10:36 PM

How do I allow my pages to use the do action like my old one?
Code:

eval('$navbar = "' . fetch_template('navbar') . '";');
if ($_REQUEST['do'] == 'support')
{
    eval('print_output("' . fetch_template('impostersupport') . '");');
}
if ($_REQUEST['do'] == 'port')
{
    eval('print_output("' . fetch_template('porthelper') . '");');
}
eval('print_output("' . fetch_template('impostergenerators') . '");');


Lynne 11-29-2010 11:16 PM

Quote:

Originally Posted by TheInsaneManiac (Post 2127353)
How do I allow my pages to use the do action like my old one?
Code:

eval('$navbar = "' . fetch_template('navbar') . '";');
if ($_REQUEST['do'] == 'support')
{
    eval('print_output("' . fetch_template('impostersupport') . '");');
}
if ($_REQUEST['do'] == 'port')
{
    eval('print_output("' . fetch_template('porthelper') . '");');
}
eval('print_output("' . fetch_template('impostergenerators') . '");');


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).

TheInsaneManiac 12-02-2010 02:26 PM

Why does this show at the top of every page?
$stylevar[htmldoctype]

Lynne 12-02-2010 04:52 PM

Quote:

Originally Posted by TheInsaneManiac (Post 2128388)
Why does this show at the top of every page?
$stylevar[htmldoctype]

That is not valid syntax for vB4. Also, what do you mean "at the top of every page"? This is an article about creating a single page. If that code is showing on every page, then it isn't an issue for this article/page.

Shadow666 12-07-2010 12:50 AM

Hi,

The copyright in the footer for the new page I was creating has now disappeared, since upgrading to vbulletin 4.1.0 PL2.

PHP Code:

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''test');
define('CSRF_PROTECTION'false);  

// ################### 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');
require_once(
'./includes/test_func_var.php');

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

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

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'test';



// ###### 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());


?>

The copyright is in the file includes/test_func_var.php

PHP Code:

<?php
$vbphrase
[powered_by_vbulletin] = '<a href="http://www.test.com">Test v1.0</a> Copyright &copy; ' date('Y') . ' <br />' $vbphrase[powered_by_vbulletin];
?>

Template test

PHP Code:

{vb:stylevar htmldoctype}
<
html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if> dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <
head>
    <
title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {
vb:raw headinclude}
    {
vb:raw headinclude_bottom}
  </
head>

  <
body>  
    {
vb:raw header}
    
    {
vb:raw navbar}

    <
div id="pagetitle">
      <
h1>{vb:raw pagetitle}</h1>
    </
div>


    {
vb:raw footer}
  </
body

</
html

Why does this no longer work.

Thanks.

Lynne 12-07-2010 01:35 AM

Are you running 4.1.0 PL2? Or PL1 or no PL at all?

Shadow666 12-07-2010 01:38 AM

Sorry, post edited. PL2

Lynne 12-07-2010 02:32 PM

Quote:

Originally Posted by Shadow666 (Post 2130283)
Sorry, post edited. PL2

did this used to work in another 4.x version? It's hard to tell what is wrong when you have not posted the template at all, nor do we know the full contents of the other file you call. What sort of debugging have you done to figure out where the problem lies?

Shadow666 12-07-2010 06:16 PM

Original post updated.

This worked fine with 4.0.x until updated to 4.1.0 PL2

Any other mods that I have installed, the copyright for them has also disappeared. e.g. VB Pro Garage Timeslips 3.0.7

Lynne 12-08-2010 01:17 AM

I don't know what you mean regarding the other mods (or what they have to do with this page). Have you tried putting the file contents directly into the main file and seeing if it works there? Or setting it to something else in the file to see if it works? Like I asked, what have you done so far to try to troubleshoot this?

And actually, you say it used to work? I could have sworn the footer template gets rendered when global.php is called, so I'm not sure how it could have worked before. And yes, I just checked and it is. You can't call your file that has a phrase to be used in the footer template *after* the footer template has been rendered.

compunerdy 12-09-2010 06:05 AM

I got the new page up and working but when I put the following code into the template it will not load the Flash file.

PHP Code:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="975" height="600" id="saberBuilder_v1.0_securityFix" align="middle">
<
param name="allowScriptAccess" value="sameDomain" />
<
param name="movie" value="saberBuilder_v1.0_cart.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="saberBuilder_v1.0_cart.swf" quality="high" bgcolor="#ffffff" width="975" height="600" name="saberBuilder_v1.0_securityFix" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</
object

If I remove the following code

PHP Code:

{vb:raw headinclude}
{
vb:raw headinclude_bottom

The flash file plays just fine but then the page does not look right. Why is this conflicting?

Any help would be great appreciated as I do not have much hair left to pull out.

Lynne 12-09-2010 02:20 PM

What exactly is the result when you put that code in the template (do you see it? Is it in the page source? etc)? Do you have a link?

compunerdy 12-09-2010 03:19 PM

It looks like it is trying to load but doesn't. Here is a link http://forums.thecustomsabershop.com...mhsbuilder.php

Lynne 12-09-2010 05:22 PM

Put in the full url for your swf.

compunerdy 12-09-2010 05:42 PM

Tried that already.. Its in there now though if you want to take a look. I can also remove those 2 lines of code to show that it loads fine without them. Something in the headinclude and headinclude_bottom make it not load. I am just not sure what.

EDIT.. Actually it does work now in firefox just not IE

DOUBLE EDIT.. added one more full URL and it works fine now.. DUH!!

Thanks and sorry for wasting your time.

Lynne 12-09-2010 06:25 PM

Can you create a second page that doesn't have the header/navbar so I can compare the two?

compunerdy 12-09-2010 06:42 PM

It works now when I put in the full URL. Evidently the headers change the working directory which made it not load without the full URL.

Lynne 12-09-2010 09:54 PM

Great! :)

stevectaylor 12-18-2010 09:21 AM

would this still work in a sub-folder?

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

I'm struggling here on a test page; Why wont it allow the 'php include' function to show.

<div class="blockbody">
<div class="blockrow">
Testing this page for php input. <?php include("offers/choice_ad1.php"); ?>
</div>
</div>

Lynne 12-18-2010 04:20 PM

Quote:

Originally Posted by stevectaylor (Post 2135824)
would this still work in a sub-folder?

--------------- Added 18 Dec 2010 at 04:34 ---------------

I'm struggling here on a test page; Why wont it allow the 'php include' function to show.

<div class="blockbody">
<div class="blockrow">
Testing this page for php input. <?php include("offers/choice_ad1.php"); ?>
</div>
</div>

You cannot put php in the template. PHP goes into the php file, and html goes into the template.

CroNiX 12-18-2010 09:09 PM

First, thank you for this. I learned a lot and have a few things planned!

When following the example, I noticed that if you went to the url:
http://www.yoursite.com/test (with no .php) the page still comes up fine, but the online locations page would break. I fixed this easily by adding an extra statement to the switch in the plugin using the online_location_process hook:

PHP Code:

switch ($filename)
{
    case 
'test':  //added this line, would need to do for each file if more than one
    
case 'test.php':  
        
$userinfo['activity'] = 'mypage';
        break;
// add more cases here if you have more than one custom page. no need for multiple plugins. one plugin can handle all.


I'm not sure if this has anything to do with the fact I'm using the mod rewrite url rules.

Lynne 12-18-2010 10:30 PM

Thanks for posting that. I'm guessing you are correct in that it has something to do with the mod rewrite rules because I can't go to just mysite.com/test and get the same page.

stevectaylor 12-19-2010 07:54 AM

Quote:

Originally Posted by Lynne (Post 2135945)
You cannot put php in the template. PHP goes into the php file, and html goes into the template.

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.


All times are GMT. The time now is 01:20 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.02321 seconds
  • Memory Usage 1,875KB
  • 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
  • (3)bbcode_code_printable
  • (6)bbcode_php_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)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