Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-11-2011, 10:40 PM
davis31b davis31b is offline
 
Join Date: Feb 2006
Location: Texas
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Including a webpage into another PHP file - NEED HELP!

I have tried every possible combination of trying to get this done and have got close, but it still isn't working correctly.

What I want to do is include my auction site, which can be viewed here: http://www.generalaviationonline.com/auction/ into a separate PHP file that I have created that was integrated into the navbar mod & used the How to create your own VB page article.

So my file, which is auction.php contains the following code:

Code:
<?php

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

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

define('THIS_SCRIPT', 'auction_plug');
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('auction',
);

// 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('' => 'Auction'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'General Aviation Auction';

$content = file_get_contents('http://www.generalaviationonline.com/auction/');
echo $content;

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

$templater = vB_Template::create('navbar_auction');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());
?>
While this is the closest code (which is highlighted in red) that I have been able to use to somewhat do what I want, when it outputs the auction site, it doesn't load it in between: vb:raw navbar & vb:raw footer, instead it displays it at the very top of the page (see attachment photo) and it doesn't even load all the images.

Any ideas what I need to do? I would even pay someone to help me fix it. Thanks!
Attached Images
File Type: jpg auction.jpg (113.4 KB, 0 views)
Reply With Quote
  #2  
Old 12-11-2011, 10:51 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Two things, why not just put the code into the page instead of this line:
PHP Code:
$content file_get_contents('http://www.generalaviationonline.com/auction/'); 
And secondly, you cannot use echo when spitting out something to a template. You need to assign the output to a variable and then spit out the variable in the template.

PHP Code:
$templater vB_Template::create('navbar_auction'); 
$templater->register_page_templates(); 
$templater->register('navbar'$navbar); 
$templater->register('pagetitle'$pagetitle);
$templater->register('content'$content );  
print_output($templater->render()); 
Reply With Quote
  #3  
Old 12-11-2011, 11:40 PM
davis31b davis31b is offline
 
Join Date: Feb 2006
Location: Texas
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didn't think about placing the code directly in the php file. Where do you feel is a good place for the code? Where I had the echo command?

And the second part is over my skill level. Thanks for the quick input.

Here is the code from my index file for the auction site, I know that I will need to add "auction/" in front of most of the directories so that it will be able to find it, but I will probably need a little help combining both php files, if someone could help me, I would be indebted to you!

Code:
<?
session_start();

define ('IN_SITE', 1);
define ('INDEX_PAGE', 1); ## for integration

if (!file_exists('includes/config.php')) echo "<script>document.location.href='install/install.php'</script>";

include_once ('includes/global.php');

include_once ('includes/functions_login.php');
include_once ('includes/functions_item.php');

if (stristr($_GET['option'], 'logout'))
{
	logout();
}

include_once ('global_header.php');

if (isset($_GET['change_language']))
{
	$all_languages = list_languages('site');

	if (in_array($_GET['change_language'], $all_languages))
	{
		$session->set('site_lang', $_GET['change_language']);
	}

	$refresh_link = 'index.php';

	$template_output .= '<br><p class="contentfont" align="center">' . MSG_SITE_LANG_CHANGED . '<br><br>
		Please click <a href="' . process_link('index') . '">' . MSG_HERE . '</a> ' . MSG_PAGE_DOESNT_REFRESH . '</p>';
	$template_output .= '<script>window.setTimeout(\'changeurl();\',300); function changeurl(){window.location=\'' . $refresh_link . '\'}</script>';
}
else if (isset($_GET['change_skin']))
{
	$all_skins = list_skins('site');

	if (in_array($_GET['default_theme'], $all_skins))
	{
		$session->set('site_theme', $_GET['default_theme']);
	}

	$refresh_link = 'index.php';

	$template_output .= '<br><p class="contentfont" align="center">' . MSG_SITE_SKIN_CHANGED . '<br><br>
		Please click <a href="' . process_link('index') . '">' . MSG_HERE . '</a> ' . MSG_PAGE_DOESNT_REFRESH . '</p>';
	$template_output .= '<script>window.setTimeout(\'changeurl();\',300); function changeurl(){window.location=\'' . $refresh_link . '\'}</script>';	
}
else
{
	include_once ('global_mainpage.php');
}

include_once ('global_footer.php');

echo $template_output;

?>
Reply With Quote
  #4  
Old 12-12-2011, 04:33 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I basically wrote the second part of the code for you. Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide That will help you understand that part of the code.

I would still not do it your way. I'd just include the code in the php file instead of in an outsite file, but that is up to you.
Reply With Quote
  #5  
Old 12-13-2011, 07:20 AM
davis31b davis31b is offline
 
Join Date: Feb 2006
Location: Texas
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Two things, why not just put the code into the page instead of this line:
PHP Code:
$content file_get_contents('http://www.generalaviationonline.com/auction/'); 
Okay, I tried this.. not working, I just want to pay someone!
Reply With Quote
  #6  
Old 12-13-2011, 04:48 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are welcome to post in the Requests For Paid Services if that is what you want.
Reply With Quote
  #7  
Old 12-15-2011, 07:30 AM
davis31b davis31b is offline
 
Join Date: Feb 2006
Location: Texas
Posts: 44
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have posted this in the PAID services area and am looking for a design similar to this screenshot I edited:

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:09 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.05522 seconds
  • Memory Usage 2,254KB
  • Queries Executed 12 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (1)postbit_attachment
  • (7)postbit_onlinestatus
  • (7)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete