Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[HOW TO - vB4] Create your own vBulletin page
Lynne's Avatar
Lynne
Join Date: Sep 2004
Posts: 41,180

 

California/Idaho
Show Printable Version Email this Page Subscription
Lynne Lynne is offline 11-15-2009, 10:00 PM

This is an updated article on how to create your own vbulletin powered page. It's only for use with vB4.

This is NOT my work. I'm posting this from another thread where vB Style took the time to write this out. And his work is based on the article by Gary King here - How to create your own vBulletin-powered page! (uses vB templates)

Instructions to Create your Own Page:


1. Create the php page:
- Create a new file, whatever you want to call it (let's say test.php).
- Open up test.php and add the following (replace TEST with whatever template you want to show - WARNING: the template name is CASE SENSITIVE!!!):
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());

?>
- Be sure to change 'TEST' to the actual template name (WARNING: the template name is CASE SENSITIVE!!!), and change 'test' to the filename or a unique name for the page. Also, change 'Test Page' and 'My Page Title' to whatever you want to show in the navbits, such as 'Viewing Member Profile' (just an example).

2. Create the Template:
- If you are in debug mode, create the template in your MASTER STYLE so it shows up in all your styles, otherwise make sure you create the template in the style you are using. If following the page above, call the template TEST (WARNING: the template name is CASE SENSITIVE!!!) with the following content:
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} - {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>
    
    <h2 class="blockhead">Title</h2>
    <div class="blockbody">
      <div class="blockrow">
        Text
      </div>
    </div>
    
    {vb:raw footer}
  </body>
</html>
.
Instructions to Add your Page to the Who's Online List (WOL):
Create two plugins using the following hooks. Replace mypage and similar with your information.

1. hook location - online_location_process:
Code:
switch ($filename)
{
    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.
}
.
2. hook location online_location_unknown:
Code:
switch ($userinfo['activity'])
{
    case 'mypage':
        $userinfo['where'] = '<a href="test.php?'.$vbulletin->session->vars[sessionurl].'">My Page</a>';
        $userinfo['action'] = "Viewing My Page";
        $handled = true;
        break;
// add more cases here if you have more than one custom page. no need for multiple plugins. one plugin can handle all.
}
.
The colored part in the code above shows what you need to change in the plugins (both reds should be the same and both blues should be the same, whereas green can be whatever you want).


Please see this article for help with rendering templates - [vB4] Rendering templates and registering variables - a short guide
Reply With Quote
  #1032  
Old 11-27-2013, 09:11 PM
mort2412 mort2412 is offline
 
Join Date: Jun 2012
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How would I go about adding an external web link to appear in the page, similar to how panjo appears

thanks
Reply With Quote
  #1033  
Old 12-23-2013, 11:08 PM
BBNZowner's Avatar
BBNZowner BBNZowner is offline
 
Join Date: Oct 2013
Location: New Zealand
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is great. Just need to sort out my text coding and it will be sweet. Might even solve a few annoying errors I've had by using CMS articles as pages instead of custom pages.
Reply With Quote
  #1034  
Old 02-05-2014, 04:54 AM
usHealthy usHealthy is offline
 
Join Date: Mar 2013
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will love to see this working on v5
Reply With Quote
  #1035  
Old 02-26-2014, 06:01 PM
FelipeB FelipeB is offline
 
Join Date: Feb 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, I'm new on this, and I'm having trouble to create a page out off the Forum root, inside the root everything is fine, but out side is without CSS...

My Forum is in:
/var/www/forum

My page is in:
/var/www/tests.php

This is my code...
Code:
// ####################### 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('/var/www/forum/');
require_once('./global.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());
and my tempate...
Code:
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} - {vb:raw pagetitle}</title>
    {vb:raw headinclude}
    {vb:raw headinclude_bottom}
  </head>
  <body>
    
    {vb:raw header}
    
    {vb:raw navbar}
    

    <div class="blockbody">
      <div class="blockrow">
		TEST
	  </div>
    </div>
    
    {vb:raw footer}
	
  </body>
</html>
Reply With Quote
  #1036  
Old 02-26-2014, 06:31 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you need to set an 'include' phrase that 'points' to the location of your css file
Reply With Quote
  #1037  
Old 02-26-2014, 06:42 PM
FelipeB FelipeB is offline
 
Join Date: Feb 2014
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could you show me?? As I say, I'm new on this, and don't have idea where is the CSS of Vbulletin...
Reply With Quote
  #1038  
Old 02-28-2014, 11:54 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Digital Jedi View Post
That would be outside the scope of the article, since that's a Facebook thing. You would need to look at their documentation or articles such as this one for what you need to do control how thumbnails show up.

Hello again,

I am creating a photography database application, so sharing pictures is an absolute must. When a person is on the "view pic" page, a facebook link is there as well so that the person can share the pic on facebook.

I am able to share the post to the person's wall, successfully, but instead of presenting a thumbnail of my desired photo, all that is being posted is a thumbnail of my forum logo. I cannot figure out how to override this and include the desired picture in the Facebook popup for posting. I tried to follow the instructions on your link, and it simply doesn't work. It's beyond a FB problem, it's intrinsic to vBulletin, and it's driving me nuts.

Before I make the dynamic solution to this problem, my goal is to first establish a static proof-of-concept. Here is the html I am using in the root directory. Notice I am intending on using the Facebook OpenGraph tool to a linked picture:

It is as if all the custom "meta" tags are being completely ignored by something inside vBulletin.

How can I include a custom pic in my Facebook Shares? Your help is greatly appreciated.

Code:
<html>
<head>
	<meta property='fb:app_id' content='473597412755690' />
	<meta property='og:site_name' content='Nature Photography Resource & Database' />
	<meta property='og:description' content='Online community for dedicated macro photographers worldwide.' />
	<meta property='og:url' content='http://www.macrophotopro.com' />
	<meta property='og:type' content='website' />
	<meta property='og:image' content='http://www.macrophotopro.com/thumbnails/1/1_thumb_0000000548_tiny.jpg'>
</head>
	
<body>
	<div id='fb-root'></div>
	<script>(function(d, s, id) {
  		var js, fjs = d.getElementsByTagName(s)[0];
  		if (d.getElementById(id)) return;
  		js = d.createElement(s); js.id = id;
  		js.src = '//connect.facebook.net/en_US/all.js#xfbml=1&appId=473597412755690';
  		fjs.parentNode.insertBefore(js, fjs);
	}
	(document, 'script', 'facebook-jssdk'));
	</script>
	
	
	<div class='fb-share-button' data-href='http://www.macrophotopro.com/' data-type='button_count'>
	</div>
</body>
</html>
A pic of what happens when I click the Facebook button is shown in the attached Pic (notice that other metatags are also being completely ignored.)

This is the picture that SHOULD be appearing on the Share:



However, the attached below (my forum logo) is what's actually getting displayed. What do I have to do to get the desired pic to override the default posting of the logo?

Help is greatly appreciated!
Attached Images
File Type: gif Facebook_Fail.gif (49.5 KB, 0 views)
Reply With Quote
  #1039  
Old 03-01-2014, 05:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Right now, if I go to your site, you have it turned off. That means an Unregistered user may not see a thing. And, if you are testing your script while it is turned off, remember that Facebook is an Unregistered User and so the only image they can grab is your logo.
Reply With Quote
  #1040  
Old 03-01-2014, 09:48 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Right now, if I go to your site, you have it turned off. That means an Unregistered user may not see a thing. And, if you are testing your script while it is turned off, remember that Facebook is an Unregistered User and so the only image they can grab is your logo.
Hi Lynne;

I am not sure I made myself clear.

What we're trying to do has nothing to do with a person being registered, logged-in, or anything like that. This has to do with a Facebook "share" button on our custom page NOT being able to share a desired image onto FB. A person should NOT have to be registered onto my site, at all, for the share button to work nor for the image to be displayed. The share button works, and the image should display because of the coding, but yet it is not.

I do understand what you're saying about the forum being turned off, but we did test the procedure with it turned on, and still got the logo, not the desired image. The meta content is structured so that the spider image should display, but yet only the logo displays.

I believe vBulletin has some static, overriding code to where only vBulletin's logo displays (or whatever logo is up there), and we are trying to circumvent or identify this code and change it.

It should have absolutely nothing to do with whether a person is logged in to our site or not. In fact, the whole idea is to advertise to NON customers of our site, to Facebook, so they can click on the FB image and be taken back to our site. These people will not be customers, so their being logged in should have no bearing on seeing the image or not.

We believe we have the coding correctly ... we have the reference to the correct thumbnail ... yet it's showing only the logo.

What overriding code to we need to get rid of to get what we want displayed, displayed?

Thanks and I hope this was clear

Jack

PS: Click this link, click the FB button, and see what I mean: http://www.macrophotopro.com/fb.html
Reply With Quote
  #1041  
Old 03-03-2014, 04:29 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello ...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:52 PM.


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.11250 seconds
  • Memory Usage 2,393KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (6)bbcode_code
  • (2)bbcode_html
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (58)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete