Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2007, 05:47 PM
MjrGaelic MjrGaelic is offline
 
Join Date: Oct 2004
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default sub pages from custom portal.

I have tried posting this question in the appropriate channels without the response so I'm hoping you coders can help.

This should be theoretically simple however I digress I'm not a coder and I can't resolve even a simple concept.

The task is to load sub_pages from smedd's portal and I want to do so without having to create additional php pages for each page I want to have. so, basically index.php?page=mypagename.

I'm ok with creating a page.php so that I can call out like page.php?do=mypagename etc.

I've gone through the API tutorial and while it partially works it uses the forum template not the index.php format.

Here is the code for my index.php
Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # SmEdD's Portal													  # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2006 Stephen "SmEdD" Medd							  # ||
|| # http://www.smedd.com | stevemedd@gmail.com 					  # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'index');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array(
	'newscache'
);

// pre-cache templates used by all actions
$globaltemplates = array(
	'smedd_index',
	'smedd_newsbits',
	'smedd_header',
	'smedd_footer'
);

$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

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

// ######################### PROCESS NEWS ############################
if (!empty($vbulletin->newscache))
{
	foreach ($vbulletin->newscache AS $news)
	{
		$vbcollapse['collapseobj_newsid'] =& $vbcollapse["collapseobj_newsbit_$news[threadid]"];
		$vbcollapse['collapseimg_newsid'] =& $vbcollapse["collapseimg_newsbit_$news[threadid]"];

		$show['reply-s'] = true;
		if ($news['replycount'] == 1)
		{
			$show['reply-s'] = false;
		}

		$news['time'] = vbdate($vbulletin->options['timeformat'], $news['dateline']);
		$news['date'] = vbdate($vbulletin->options['dateformat'], $news['dateline'], 1);
		eval('$newsbits .= "' . fetch_template('smedd_newsbits') . '";');
	}

	// memory saving
	unset($newscache, $news);
}

// #################### EVAL GLOBAL TEMPLATES #######################
// Clear the header and footer variables so we can set them again without problems!
unset($header, $footer);

$vbphrase['powered_by_vbulletin'] = "Home page powered by SmEdD's Portal, Copyright &copy;2006, Stephen Medd.<br />\n" . $vbphrase['powered_by_vbulletin'];

// Output all the templates
eval('$header = "' . fetch_template('smedd_header') . '";');
eval('$footer = "' . fetch_template('smedd_footer') . '";');
if ($shownewpm)
{
	eval('$footer .= "' . fetch_template('pm_popup_script') . '";');
}

eval('print_output("' . fetch_template('smedd_index') . '");');
?>
I've tried adding:
Code:
if ($_REQUEST['do'] == 'ventrilo')
{
    eval('print_output("' . fetch_template('page_ventrilo') . '");');
}
but nothing happens (ventrilo is the example, and the templates name is page_ventrilo)

If possible what I would like to have is a piece of code in the page that would call out custom templates.. I know vbadvanced does this seamlessly but I don't want to run vbadvanced, just syndicate news and add my own content.

Can anyone offer a suggestion or 2 to point me in the right direction?

If you need, the context of the project is here so you can see what I'm working towards.

Kind regards,

Ryan
Reply With Quote
  #2  
Old 09-23-2007, 09:54 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't say where you added that code - but remember that you can only call print_output once() - once you call that, the page is output and execution ends.
Reply With Quote
  #3  
Old 09-25-2007, 12:42 AM
MjrGaelic MjrGaelic is offline
 
Join Date: Oct 2004
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for responding Paul,

I placed the last bit of code at the end of the page before the final ?> as instructed in the tutorial I read.

How do I set the print_out to be dynamic so that I can generate URL's like page.php?do=mypage where mypage is a template.
Reply With Quote
  #4  
Old 09-25-2007, 05:22 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # SmEdD's Portal                                                      # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2006 Stephen "SmEdD" Medd                              # ||
|| # http://www.smedd.com | stevemedd@gmail.com                       # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT''index');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array(
    
'newscache'
);

// pre-cache templates used by all actions
$globaltemplates = array(
    
'smedd_index',
    
'smedd_newsbits',
    
'smedd_header',
    
'smedd_footer'
);

$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

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

// ######################### PROCESS NEWS ############################
if (!empty($vbulletin->newscache))
{
    foreach (
$vbulletin->newscache AS $news)
    {
        
$vbcollapse['collapseobj_newsid'] =& $vbcollapse["collapseobj_newsbit_$news[threadid]"];
        
$vbcollapse['collapseimg_newsid'] =& $vbcollapse["collapseimg_newsbit_$news[threadid]"];

        
$show['reply-s'] = true;
        if (
$news['replycount'] == 1)
        {
            
$show['reply-s'] = false;
        }

        
$news['time'] = vbdate($vbulletin->options['timeformat'], $news['dateline']);
        
$news['date'] = vbdate($vbulletin->options['dateformat'], $news['dateline'], 1);
        eval(
'$newsbits .= "' fetch_template('smedd_newsbits') . '";');
    }

    
// memory saving
    
unset($newscache$news);
}

// #################### EVAL GLOBAL TEMPLATES #######################
// Clear the header and footer variables so we can set them again without problems!
unset($header$footer);

$vbphrase['powered_by_vbulletin'] = "Home page powered by SmEdD's Portal, Copyright &copy;2006, Stephen Medd.<br />\n" $vbphrase['powered_by_vbulletin'];

// Output all the templates
eval('$header = "' fetch_template('smedd_header') . '";');
eval(
'$footer = "' fetch_template('smedd_footer') . '";');
if (
$shownewpm)
{
    eval(
'$footer .= "' fetch_template('pm_popup_script') . '";');
}

if (
$_REQUEST['do'] == 'ventrilo')
{
    eval(
'print_output("' fetch_template('page_ventrilo') . '");');
}
else
{
    eval(
'print_output("' fetch_template('smedd_index') . '");');
}
?>
Reply With Quote
  #5  
Old 09-25-2007, 05:16 PM
MjrGaelic MjrGaelic is offline
 
Join Date: Oct 2004
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you dismounted, I'll try that this evenin when I get home. As I plan to add many pages to the site am I correct that I will be adding code for each page like:

Code:
if ($_REQUEST['do'] == 'ventrilo')
{
    eval('print_output("' . fetch_template('page_ventrilo') . '");');
}
else
{
if ($_REQUEST['do'] == 'page1')
{
    eval('print_output("' . fetch_template('page_page1') . '");');
}
else
{
if ($_REQUEST['do'] == 'page2')
{
    eval('print_output("' . fetch_template('page_page2') . '");');
}
else
{
and so on?
Reply With Quote
  #6  
Old 09-26-2007, 06:45 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
if ($_REQUEST['do'] == 'ventrilo')
{
    eval(
'print_output("' fetch_template('page_ventrilo') . '");');
}
else if (
$_REQUEST['do'] == 'page1')
{
    eval(
'print_output("' fetch_template('page_page1') . '");');
}
else if (
$_REQUEST['do'] == 'page2')
{
    eval(
'print_output("' fetch_template('page_page2') . '");');
}
else
{
    eval(
'print_output("' fetch_template('smedd_index') . '");');

Reply With Quote
  #7  
Old 09-26-2007, 04:37 PM
Opserty Opserty is offline
 
Join Date: Apr 2007
Posts: 4,103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use switch as opposed to multiple elseif's I'm pretty sure they work as expected in vB.

http://php.net/switch
Reply With Quote
  #8  
Old 09-26-2007, 11:36 PM
MjrGaelic MjrGaelic is offline
 
Join Date: Oct 2004
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you Dismounted. For clenliness sake I've actually created a page.php and call the evals from there..

Opserty, what advantage is switch over what has been presented. I looked it over and it looked like I'd need a good sit down and a coffee to apply it.
Reply With Quote
  #9  
Old 09-27-2007, 05:04 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Converted to switches .
PHP Code:
switch ($_REQUEST['do'])
{
    case 
'ventrilo':
        eval(
'print_output("' fetch_template('page_ventrilo') . '");');
        break;
    case 
'page1':
        eval(
'print_output("' fetch_template('page_page1') . '");');
        break;
    case 
'page2':
        eval(
'print_output("' fetch_template('page_page2') . '");');
        break;
    default:
        eval(
'print_output("' fetch_template('smedd_index') . '");');
        break;

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 10:02 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.04666 seconds
  • Memory Usage 2,281KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete