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 05-02-2010 01:59 PM

Quote:

Originally Posted by FCS-Webmaster (Post 2030519)
How do I include Widgets to my own vBulletin page?

You'd have to write the code to include them. I do not have that code - you will have to go look through the files yourself.

aaronater 05-02-2010 02:21 PM

Hey :)

What if I wanted to just clone the Home page? Meaning the first tab on the navbar 'Home' when you click it it takes you to the Home page where you can add articles. If I want a new page, lets call it 'Zome' I can make the new navbar tab called 'Zome' but what about the content page to go with it?

Thanks

caciocode 05-02-2010 02:56 PM

The next part has become complicated for me. I even have no idea where to place those scripts.

aaronater 05-02-2010 04:45 PM

OK I worked it out, thanks.

firefoxx 05-09-2010 07:17 PM

Hi,

I have a flatcast radio. So I added the following code to the php file.

Code:

$HTML .='<div align="center"><IFRAME height="500">.......</IFRAME></div>'
So when I go to radio.php I see nothing.

Davidinh 05-10-2010 03:23 PM

1 Attachment(s)
How to view a item from database
i have create a test page that followed this tutorial
it work fine but i want to connect some item into the database

the test.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';

// ##### Initialize categories connection ####
$category = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "testing order by name DESC");
                while ($categories = $db->fetch_array($film))
        // initialize each item { }
$db->free_result($category);

// ###### 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 template is exactly as the first post

within data table i dunno how to put (variable of item) into the template page and they will show in the page

any help will be appriciated

also help create the xml file for this test if you guy needed
i create it on local machine therefore i don't have a link

Lynne 05-10-2010 07:43 PM

If your variable name is $categories, then register it for use in the template:
PHP Code:

$templater->register('categories'$categories); 

and then use it in the template like this:
HTML Code:

{vb:raw categories.whatever}

Davidinh 05-10-2010 09:10 PM

thanks Lynne

I tried it but nothing show
Code:

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

seem to be not array

Lynne 05-10-2010 09:31 PM

Well, you never did anything with $categories, so nothing is going to show up from it. You just have an empty while loop (and not even really that).

Davidinh 05-11-2010 12:12 AM

thanks for reply Lynne but i still dunno what is exactly your point and this is a point i'm not really got it
so, i'm going to put something in while loop like
Code:

// ##### Initialize categories connection ####
$category = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "testing order by name DESC");
                while ($categories = $db->fetch_array($category))
        // initialize each item
        {
            $name = $categories['name'];
            $des = $categories['des'];
        }
$db->free_result($category);

and the code line in template
{vb:raw categories.name}
do i have register the varialbe ($name, $des) for template?

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

and i tried to register them under $categories :
Code:

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

$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('categories', $categories);
$templater->register('categories', $name);
$templater->register('categories', $des);
print_output($templater->render());

it shows the first letter of the first item in database only
the first item name: testing 1
it shows "t" only :confused:

Lynne 05-11-2010 01:58 AM

You would have to do something in here if you are in a loop:
PHP Code:

        {
            
$name $categories['name'];
            
$des $categories['des'];
$templater vB_Template::create('TEST_1');
$templater->register_page_templates();
$templater->register('name'$name);
$templater->register('des'$des);
$my_output .= $templater->render();
        }

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

I strongly suggest you take a look at some of the code in files like forum.php where there is a while loop.

EQmandingo 05-11-2010 03:43 AM

i was wondering..... is there a way i can add a forum to display on this custom page say for example the default main forum...or rather just the posts from that forum itself and if so how can i do this.

by the way.. this is by far one of my favorite things i have seen here at vb.org thank you so much.

Lynne 05-11-2010 03:46 AM

Quote:

Originally Posted by EQmandingo (Post 2034914)
i was wondering..... is there a way i can add a forum to display on this custom page say for example the default main forum...or rather just the posts from that forum itself and if so how can i do this.

You would just do a query to grab the threads/posts from that forum and then display them on the page. There is a thread here about this very thing that I answered today. It's out in the main forums, but I posted a basic query in there as an idea of how to do it. (Of course, you can just open up any vB file to see how to do it also.)

EQmandingo 05-11-2010 04:05 AM

Quote:

Originally Posted by Lynne (Post 2034916)
You would just do a query to grab the threads/posts from that forum and then display them on the page. There is a thread here about this very thing that I answered today. It's out in the main forums, but I posted a basic query in there as an idea of how to do it. (Of course, you can just open up any vB file to see how to do it also.)

WOW!! Could you please link me to said thread and possibly with the post # if its that hot of a thread ... would love to know exactly how to do that the right way.

Btw It is you I am thanking for this thread...I love to try out products but things like this is what helps me understand how to better operate and modify vbulletin. So a proper thank you for this thread and your lightning response to my question :-) :up:

Davidinh 05-11-2010 10:54 AM

thank you Lynne

from the post #291
that mean i have to create more tepmlate as TEST_1 for initial part of category. is it correct Lynne ! :)

i am going to try it and let you know thanks again Lynne

but how about template code

i will use {vb:raw my_output.part of loop}
(part of loop : $ name, $des right !!! or till the same
{vb:raw categories.whatever}
(whatever : name, des )

would you please ...... Lynne

Lynne 05-11-2010 02:02 PM

Quote:

Originally Posted by EQmandingo (Post 2034922)
WOW!! Could you please link me to said thread and possibly with the post # if its that hot of a thread ... would love to know exactly how to do that the right way.

All I've posted is some basic info to get started, I did not write the whole page for him - Help calling new threads to a custom page help

Quote:

Originally Posted by Davidinh (Post 2035084)
thank you Lynne

from the post #291
that mean i have to create more tepmlate as TEST_1 for initial part of category. is it correct Lynne ! :)

i am going to try it and let you know thanks again Lynne

but how about template code

i will use {vb:raw my_output.part of loop}
(part of loop : $ name, $des right !!! or till the same
{vb:raw categories.whatever}
(whatever : name, des )

would you please ...... Lynne

You need to get the info in order to spit it out. In your original code, you never got the info. You did a query, wrote a while loop to do something with the info from the query, but never actually did anything with it. So, there was nothing to output. Take a look at the forum.php page and how they grab the currently active users. You make a query, then go into a while loop and spit out the user info into a template, then after you get out of the while loop, you spit all that template info out into another template.

Davidinh 05-11-2010 03:34 PM

thanks Lynne
i got it, the way template work on VB4

Once again thanh you very much for your time Lynne
i thought i need one more step about how to use a file CSS or connected it into a template

i am going to create the TEST.css template (with google grids or kind of CSS for 2 or 3 columns) then
on the top (head part) of the main page of cust_page put this link in
Code:

<link rel="stylesheet" type="text/css" href="{vb:var vbcsspath}TEST.css" />
  </head>

So, it should be completed your tutorial "How create a custom page for VB 4"


thanks for all who distribute this knowlege

Best regard,

alfanexus 05-14-2010 01:13 PM

Would it be possible to put a widget on such a page? If then how?

Lynne 05-14-2010 01:36 PM

Possible? Almost anything is possible if you code it. I do not know how to put a widget on the page, however, and I imagine it would be a lot more coding that just putting a custom block of your own on the page would be.

Davidinh 05-15-2010 04:12 PM

how to create multiple template under $_REQUEST[do] Lynne

i tried to get more template (on test.php)
but i don't understand how to make a second template for it

any help !

Lynne 05-15-2010 06:30 PM

Quote:

Originally Posted by Davidinh (Post 2037441)
how to create multiple template under $_REQUEST[do] Lynne

i tried to get more template (on test.php)
but i don't understand how to make a second template for it

any help !

You just render a different template per do usually:
PHP Code:

if ($_REQUEST['do'] == 'this'){
$templater vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());
}

if (
$_REQUEST['do'] == 'that'){
$templater vB_Template::create('TEST2');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());



Davidinh 05-15-2010 08:32 PM

thank you Lynne
in the template "TEST2" it has carry on the head and footer like the template TEST
is it correct ?

Lynne 05-15-2010 09:00 PM

TEST2 would look like whatever you make it to look like. You could even just use the exact same template, TEST, if you have the same variable names and such. I'm just giving an example in my post.

Davidinh 05-15-2010 09:26 PM

i got a second template as you sample. Lynne thanks
but i can put out the info from database (it's blank) it's so complicated to me

Code:

// initialize db content
$view = $db->query_read(
        "SELECT d.*, c.*
        FROM " . TABLE_PREFIX . "doc AS d
        LEFT JOIN " . TABLE_PREFIX . "doc_cat AS c ON (d.id = c.catid)
        WHERE c.catid = '$docid'
");
    while ($viewer = $db->fetch_array($view))
    {
        $title = $viewer['docname'];
        $content = $viewer['document'];
        $describe = $viewer['docdes'];
        $press = vbdate($vbulletin->options['dateformat'], $viewer['postdate']);
// register templates
    $templater = vB_Template::create('TEST_2');
    $templater->register_page_templates();
    $templater->register('docid', $docid);
    $templater->register('viewer', $viewer);
    $templater->register('title', $title);
    $templater->register('content', $content);
    $templater->register('describe', $describe);
    $templater->register('press', $press);
$my_doc_view .= $templater->render();
    }
   
$db->free_result($view);
// start the navbar
$navbits = array();
$navbits['test.php?' . $vbulletin->session->vars['sessionurl_q'] . ""] = "Create Own Page";
$navbits[''] = "Test Viewer";

$templater = vB_Template::create('TEST2');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('my_doc_view', $my_doc_view);
    $templater->register('viewer', $viewer);
    $templater->register('title', $title);
    $templater->register('content', $content);
    $templater->register('describe', $describe);
    $templater->register('press', $press);
    $templater->register('my_cat', $my_cat);
print_output($templater->render());
{

in the template TEST2 (like i do for categories is work fine in the front page)
i insert these line
{vb:raw my_doc_view} (the other template i call TEST_2)
and in the template TEST_2 i tried to point some info that i already register :
{vb:raw title}
{vb:raw content}

then i got a blank view

any idea Lynne

Lynne 05-15-2010 10:44 PM

Quote:

Originally Posted by Davidinh (Post 2037593)
then i got a blank view

any idea Lynne

If you need help getting the queries working and such, then you really need to post in the main forums. I can't go through everyone's code that posts in this thread.

And if you are getting a blank page, it could be that you didn't put the template into the style you are using to view your page.

Davidinh 05-16-2010 10:14 AM

oh okay Lynne, thanks for your time

but the problem it not on the second template page It shows out fine without the info that i try to put out from database
however, sorry about mess up the posting here Lynne

Sincerely,

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

well, finally, i got them all Lynne
thank you for you time

I took the sample from file profile.php of vbb4 and study the way they used the template "USERCP_SHELL" and apply your tutorial

and now my test page it word great
some kind of variable as
Code:

// set shell template name
$shelltemplatename = 'USERCP_SHELL';

then it drops down the # of register template
Just call variable by {vb:raw whatever}

hope this help somebody who likes me :))
Sincerely,

kardus 05-18-2010 03:49 AM

I did this and it works perfectly. Unfortunately it won't work with PHP files that I am trying to include in my custom page. I made a thread about it here: https://vborg.vbsupport.ru/showthread.php?p=2038959

Can Lynne (or anyone?) help me get this working?

Lynne 05-18-2010 02:21 PM

It looks like Cellarius helped you out and you are now up and running. :)

FCS-Webmaster 05-27-2010 08:23 PM

can anyone help me with this one - so I'll be able to convert all my old codes to the new vbulletin system? heres the thread I made with a describtion of my problem

thezman 06-01-2010 10:12 PM

I have a simple question. I want a customer page that displays a table I created in Dreamweaver. Where do I place the html to have it display on my customer page?

Lynne 06-02-2010 03:49 AM

Quote:

Originally Posted by thezman (Post 2046745)
I have a simple question. I want a customer page that displays a table I created in Dreamweaver. Where do I place the html to have it display on my customer page?

html goes in the template.

thezman 06-02-2010 07:32 PM

Quote:

Originally Posted by Lynne (Post 2046876)
html goes in the template.

Then I have a problem somewhere. I tested with a simple bit of code (<b>Test</b>) right in the section that says customer code goes here. I get an error. I take out the code and the error goes away.

Further, the page is viewable (unmodified) but not as a part of the VB framework. It is just blank page, without the tabs, headings and so forth.

Lynne 06-02-2010 10:54 PM

Quote:

Originally Posted by thezman (Post 2047254)
Then I have a problem somewhere. I tested with a simple bit of code (<b>Test</b>) right in the section that says customer code goes here. I get an error. I take out the code and the error goes away.

Further, the page is viewable (unmodified) but not as a part of the VB framework. It is just blank page, without the tabs, headings and so forth.

It is the php page that says "Custom Code Goes Here" - that is not the template. The template is the thing created in Step 2. Did you do that? And did you create the template in the Style you are currently using on your site? If you don't, then you will get a blank page.

Percocet 06-07-2010 11:10 PM

So after you create the new test.php and the new template how do you get them to show up on your site? I assume you place the template in your template files, but what do you do with the test.php file?

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

Ok i figured it out. You just place it in the main VBULLETIN folder that will be titled "forum" if you followed the install directions exactly as they are on the vb website :)

Lynne 06-07-2010 11:42 PM

You need to upload test.php to your site.

Wilfred1 06-11-2010 10:17 PM

From an SEO perspective is it better to have the html code in the php file instead of using a template?

Lynne 06-12-2010 03:48 AM

Really? Why?

You can put the php in the php file, it's just not as easy as using a template, but you are free to do it however you want.

Wilfred1 06-12-2010 04:12 AM

Thanks Lynne - but I am just asking which way is better for SEO or doesn't it matter as the bots will find it all just the same?

ragtek 06-12-2010 08:04 AM

It doesn't matter

jdrakopo 06-23-2010 12:28 PM

Thanks for posting this.
However, I'm receiving the following error on my page:
>> Parse error: syntax error, unexpected T_VARIABLE in /home/bostonwh/public_html/adhub.php on line 44

...where line 44 is as follows:
$templater = vB_Template::create('adhub');

... and I DO have a template defined by that name which is identical to what you have above (though, I'm wondering if it's acceptable for me to have 'test' and 'TEST' be the same term - which in my case is 'adhub' for both)


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

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.02820 seconds
  • Memory Usage 1,874KB
  • 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
  • (1)bbcode_html_printable
  • (3)bbcode_php_printable
  • (10)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