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
  #1042  
Old 03-03-2014, 06:28 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I really don't know enough about Facebook and their code to help out on this.
Reply With Quote
  #1043  
Old 03-06-2014, 11:34 AM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
I really don't know enough about Facebook and their code to help out on this.
Really? You're one of the top people at vBulletin and you "can't help" with Facebook?

Wow.

You can't explain why the Blog and the Forum, when their links are Shared or physically-added to a Facebook wall, that those links display a list of images to select from ... while this custom page does NOT?

Really? You can't explain that or give help to overcome this?

Impressive. Thanks.
Reply With Quote
  #1044  
Old 03-06-2014, 11:54 AM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your negative reply to Lynne is not a pleasant invitation for others to help you. You might want to rethink abusing the volunteers in this community. This is an enthusiast community for vBulletin, and is not official vBulletin support. If you would like help please be nice, we try to be.
Reply With Quote
2 благодарности(ей) от:
K4GAP, ozzy47
  #1045  
Old 03-06-2014, 12:01 PM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
Your negative reply to Lynne is not an inviting message to receive assistance from others. Who needs this kind of abuse when we are already volunteering our time. If you would like help please be nice.
Correct, and just because some one is considered a "top person" does not mean they know all there is to know about vBulletin, or a third party integration such as Facebook, I my self have over 60 mods released, and I could not tell you one thing about it, I don't even have a Facebook page.
Reply With Quote
  #1046  
Old 03-06-2014, 12:08 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When I have a chance I will take a look at your code, but I am currently working on a backlog of tasks for other vbulletin.org members.
Reply With Quote
  #1047  
Old 03-06-2014, 12:12 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ozzy47 View Post
Correct, and just because some one is considered a "top person" does not mean they know all there is to know about vBulletin, or a third party integration such as Facebook, I my self have over 60 mods released, and I could not tell you one thing about it, I don't even have a Facebook page.
Fair enough then.
Reply With Quote
Благодарность от:
ozzy47
  #1048  
Old 03-06-2014, 12:18 PM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MacroPhotoPro View Post
Fair enough then.
Believe me, I know how frustrating things are when they don't work as intended, or as you would like them to. I have spent many hours yelling at my screen when things don't go my way.

The people here will do their best to help anyone out, and yes it can get quite aggravating when things just won't cooperate, but patience is a virtue.

Hopefully someone here has ran into the issue before, and can help out.
Reply With Quote
Благодарность от:
tbworld
  #1049  
Old 03-06-2014, 12:18 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
When I have a chance I will take a look at your code, but I am currently working on a backlog of tasks for other vbulletin.org members.
I would appreciate this greatly.

I have been working on the customization of this site for 2 years, and we're ready to launch. The entire sum & substance of our functionality and advertisement hinges on these custom image pages being able to be "Shared" onto Facebook walls ... so the author of this tutorial "not knowing how" to connect and override to FB is no small omission.

Thanks again.

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

Here is an example of one of our Image pages:


I have coded the button to share the post to the person's wall, successfully, but instead of presenting a thumbnail of the desired photo, all that is being posted is a thumbnail of my forum logo, as such:


Failed vBulletin Custom Share showing Forum Logo

I don't want my forum logo displayed; I want a thumbnail of the desired image displayed. I cannot figure out how to override this glitch and include the desired picture in the Facebook popup for posting, rather than my logo.

I know it is possible to get the desired image, and I thought I had coded it as such. For example, in the vBulletin Blog, when I use the Facebook Share Button there, I see the image I am trying to share *plus* the option for other images on the page:


Successful Blog Post Share showing Desired Image

When using the Blog, if I post the same 2 images and try to share them there, when the "Share pop-up" displays, you will notice that not only is the individual image that I want available to share, but that I have a total list of the 2 photos I can sort through and select from to share as well ... but I get no such thing from this vBulletin custom page!

Again, here is my code:

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>
It is as if all the "meta" tags on this custom page are being completely ignored by something inside vBulletin. Yet somehow they are able to get through on the forum and blog postings. I tried to follow the FB Developer instructions, and it simply doesn't work. I believe this is beyond a FB problem, it's a problem intrinsic to some omission in this vBulletin custom page, and it's driving me nuts.

What do I have to do to get the desired pic to override the default posting of the vBulletin logo? I am willing to pay for this $ervice, so PM me your price!

Thank you,

Jack

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

Quote:
Originally Posted by ozzy47 View Post
Believe me, I know how frustrating things are when they don't work as intended, or as you would like them to. I have spent many hours yelling at my screen when things don't go my way.

The people here will do their best to help anyone out, and yes it can get quite aggravating when things just won't cooperate, but patience is a virtue.

Hopefully someone here has ran into the issue before, and can help out.
Thank you.
Reply With Quote
  #1050  
Old 03-06-2014, 12:40 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I added you to my cue. Actually, I added you several days ago, but since I had a backlog already I did not answer. Obviously, I have to mock this up and it will be a three-four days minimum before I can get into it. Some members here have been waiting for my time for four weeks since my work sent me to Sochi for the Olympics. If you can be patient I can help.
Reply With Quote
  #1051  
Old 03-06-2014, 01:09 PM
MacroPhotoPro MacroPhotoPro is offline
 
Join Date: Feb 2012
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tbworld View Post
I added you to my cue. Actually, I added you several days ago, but since I had a backlog already I did not answer. Obviously, I have to mock this up and it will be a three-four days minimum before I can get into it. Some members here have been waiting for my time for four weeks since my work sent me to Sochi for the Olympics. If you can be patient I can help.
Okay, thank you. Let me know.

Cheers,
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 12:27 AM.


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.05885 seconds
  • Memory Usage 2,382KB
  • 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
  • (4)bbcode_code
  • (1)bbcode_html
  • (7)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
  • (62)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete