Jump to content

Adding a new php page


SemperFi

Recommended Posts

I want to move my portfolio (which is currently a sitedoc) to its own php page

I have created these :

root/portfolio.php

<?php

/*

+--------------------------------------------------------------------------

|   CubeCart v3.0.10

|   ========================================

|   by Alistair Brookbanks

|	CubeCart is a Trade Mark of Devellion Limited

|   Copyright Devellion Limited 2005 - 2006. All rights reserved.

|   Devellion Limited,

|   22 Thomas Heskin Court,

|   Station Road,

|   Bishops Stortford,

|   HERTFORDSHIRE.

|   CM23 3EE

|   UNITED KINGDOM

|   http://www.devellion.com

|	UK Private Limited Company No. 5323904

|   ========================================

|   Web: http://www.cubecart.com

|   Date: Tuesday, 14th March 2006

|   Email: info (at) cubecart (dot) com

|	License Type: CubeCart is NOT Open Source Software and Limitations Apply 

|   Licence Info: http://www.cubecart.com/site/faq/license.php

+--------------------------------------------------------------------------

|	portfolio.php

|   ========================================

|	Portfolio pages of the store	

+--------------------------------------------------------------------------

*/

	include_once("includes/ini.inc.php");

	

	

	

	// INCLUDE CORE VARIABLES & FUNCTIONS

	include_once("includes/global.inc.php");

	

	// check if installed

	if($glob['installed']==0){

	

		header("location: install/index.php");

		exit;

		

	} elseif((file_exists($glob['rootDir']."/install/index.php") || file_exists($glob['rootDir']."/upgrade.php") && $glob['installed']==1)){

	

		echo "<strong>WARNING</strong> - Your store will not function until the install directory and/or upgrade.php is deleted from the server.";

		exit;

		

	}

	

	// initiate db class

	include_once("classes/db.inc.php");

	$db = new db();

	include_once("includes/functions.inc.php");

	$config = fetchDbConfig("config");

	

	include_once("includes/sessionStart.inc.php");

	

	include_once("includes/sslSwitch.inc.php");

	

	// get session data

	include_once("includes/session.inc.php");

	

	// get exchange rates etc

	include_once("includes/currencyVars.inc.php");

	

	$lang_folder = "";

	

	if(empty($ccUserData[0]['lang'])){

		$lang_folder = $config['defaultLang'];

	} else {

		$lang_folder = $ccUserData[0]['lang'];

	}

	include_once("language/".$lang_folder."/lang.inc.php");

	

	// require template class

	include_once("classes/xtpl.php");

	

	$body = new XTemplate ("skins/".$config['skinDir']."/styleTemplates/global/portfolio.tpl");



	if(isset($_GET['searchStr'])){

		$body->assign("SEARCHSTR",treatGet($_GET['searchStr']));

	} else {

		$body->assign("SEARCHSTR","");

	}

	

	$body->assign("CURRENCY_VER",$currencyVer);

	$body->assign("VAL_ISO",$charsetIso);

	$body->assign("VAL_SKIN",$config['skinDir']);

		

	// START  MAIN CONTENT

	if(isset($_GET['act'])){

	

		switch (treatGet($_GET['act'])) {



			case "viewDoc":

				include("includes/content/viewDoc.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break; 

			case "viewCat":

				include("includes/content/viewCat.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;

			case "viewProd":

				include("includes/content/viewProd.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;

			case "unsubscribe":

				include("includes/content/unsubscribe.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;

			case "taf":

				include("includes/content/tellafriend.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;

			case "login":

				include("includes/content/login.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break; 

			case "logout":

				include("includes/content/logout.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break; 

			case "forgotPass":

				include("includes/content/forgotPass.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break; 

			case "account":

				include("includes/content/account.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break; 

			case "profile":

				include("includes/content/profile.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;	 

			case "changePass":

				include("includes/content/changePass.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;

			case "newsletter":

				include("includes/content/newsletter.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;

			case "cnThanks":

				include("includes/content/cnThanks.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break; 

			case "dnExpire":

				include("includes/content/dnExpire.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break; 

			default:

				include("includes/content/portfolio.inc.php");

				$body->assign("PAGE_CONTENT",$page_content);

			break;

		}

		

	} else {

		

		include("includes/content/portfolio.inc.php");

		$body->assign("PAGE_CONTENT",$page_content);

	

	}

	// END MAIN CONTENT

	

	// START META DATA

	if(isset($meta)){

		$body->assign("META_TITLE",htmlspecialchars($meta['siteTitle']).c());

		$body->assign("META_DESC",$meta['metaDescription']);

		$body->assign("META_KEYWORDS",$config['metaKeyWords']);

	} else {

		$body->assign("META_TITLE",htmlspecialchars($config['siteTitle']).c());

		$body->assign("META_DESC",$config['metaDescription']);

		$body->assign("META_KEYWORDS",$config['metaKeyWords']);

	}

	

	// START CONTENT BOXES

	include("includes/boxes/searchForm.inc.php");

	$body->assign("SEARCH_FORM",$box_content);

	

	include("includes/boxes/session.inc.php");

	$body->assign("SESSION",$box_content);



	include("includes/boxes/categories.inc.php");

	$body->assign("CATEGORIES",$box_content);

	

	include("includes/boxes/randomProd.inc.php");

	$body->assign("RANDOM_PROD",$box_content);

	

	include("includes/boxes/info.inc.php");

	$body->assign("INFORMATION",$box_content);

	

	include("includes/boxes/language.inc.php");

	$body->assign("LANGUAGE",$box_content);



	include("includes/boxes/sponsor1.inc.php");

	$body->assign("SPONSOR1",$box_content);	



	include("includes/boxes/sponsor2.inc.php");

	$body->assign("SPONSOR2",$box_content);



	include("includes/boxes/adsense.inc.php");

	$body->assign("ADSENSE",$box_content);

	

	include("includes/boxes/currency.inc.php");

	$body->assign("CURRENCY",$box_content);

	

	include("includes/boxes/shoppingCart.inc.php");

	$body->assign("SHOPPING_CART",$box_content);

	

	include("includes/boxes/popularProducts.inc.php");

	$body->assign("POPULAR_PRODUCTS",$box_content);

	

	include("includes/boxes/saleItems.inc.php");

	$body->assign("SALE_ITEMS",$box_content);

	

	include("includes/boxes/mailList.inc.php");

	$body->assign("MAIL_LIST",$box_content);

	

	include("includes/boxes/siteDocs.inc.php");

	$body->assign("SITE_DOCS",$box_content);



	include("includes/boxes/siteDocs2.inc.php");

	$body->assign("SITE_DOCS2",$box_content);

	// END CONTENT BOXES

	

	// parse and spit out final document

	$body->parse("body");

	$body->out("body");

?>




includes/content/portfolio.inc.php


<?php 

/*

+--------------------------------------------------------------------------

|   CubeCart v3.0.10

|   ========================================

|   by Alistair Brookbanks

|	CubeCart is a Trade Mark of Devellion Limited

|   Copyright Devellion Limited 2005 - 2006. All rights reserved.

|   Devellion Limited,

|   22 Thomas Heskin Court,

|   Station Road,

|   Bishops Stortford,

|   HERTFORDSHIRE.

|   CM23 3EE

|   UNITED KINGDOM

|   http://www.devellion.com

|	UK Private Limited Company No. 5323904

|   ========================================

|   Web: http://www.cubecart.com

|   Date: Tuesday, 14th March 2006

|   Email: info (at) cubecart (dot) com

|	License Type: CubeCart is NOT Open Source Software and Limitations Apply 

|   Licence Info: http://www.cubecart.com/site/faq/license.php

+--------------------------------------------------------------------------

|	portfolio.inc.php

|   ========================================

|	The Portfolio :O)	

+--------------------------------------------------------------------------

*/



if (ereg(".inc.php",$HTTP_SERVER_VARS['PHP_SELF'])) {

	echo "<html>\r\n<head>\r\n<title>Forbidden 403</title>\r\n</head>\r\n<body><h3>Forbidden 403</h3>\r\nThe document you are requesting is forbidden.\r\n</body>\r\n</html>";

	exit;

}



$index=new XTemplate ("skins/".$config['skinDir']."/styleTemplates/content/portfolio.tpl");



include("language/".$lang_folder."/home.inc.php");



if($home['enabled']==0){



	include("language/".$config['defaultLang']."/home.inc.php");



}



$index->assign("HOME_TITLE",validHTML(stripslashes($home['title'])));

$index->assign("HOME_CONTENT",stripslashes($home['copy']));



$portfolio->parse("portfolio");

$page_content = $portfolio->text("portfolio");

?>




styleTemplates/global/portfolio.tpl


<!-- BEGIN: body -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset={VAL_ISO}" />

<title>{META_TITLE}</title>

<meta name="description" content="{META_DESC}" />

<meta name="keywords" content="{META_KEYWORDS}" />

<link href="skins/{VAL_SKIN}/styleSheets/style.css" rel="stylesheet" type="text/css" />

<link href="skins/{VAL_SKIN}/styleSheets/layout.css" rel="stylesheet" type="text/css" />

<script language="javascript" src="js/jslibrary.js" type="text/javascript"></script>

</head>



<body>

<!-- Start Header Table -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

	<td>

	<table width="100%" border="0" cellspacing="0" cellpadding="0">

	 <tr>

			<!-- Start Header Images -->

	   <td width ="263" background="skins/{VAL_SKIN}/styleImages/header/header_bg.jpg"><img style="margin:0px;"src="skins/{VAL_SKIN}/styleImages/header/semperfiphotography_header.gif"></td>

	  <!-- End Header Images -->

	  <!-- Start Header Right -->

	   <td><table width="100%" height="88" border="0" cellspacing="0" cellpadding="0" background="skins/{VAL_SKIN}/styleImages/header/header_bg.jpg">

		 <tr>

		   <td style="padding-right: 9px; padding-top: 0px;" align="right" valign="top">{SITE_DOCS}</td>

		 </tr>

		 <tr>

		   <td style="padding-right: 9px; padding-top: 25px;" align="right" valign="top">{SEARCH_FORM}</td>

		 </tr>

	   </table></td>

	   <!-- End Header Right -->

	 </tr>

   </table>



<!-- Start Top Menu -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">

	<tr width="100%">

	<td height="30" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_bg.gif">&nbsp;</td>

	<td height="30" width="1" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_delim.gif">&nbsp;</td>

	<td height="30" width="130" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_bg.gif"><a href="index.php" class="top-menu-title">Home</a></td>

	<td height="30" width="1" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_delim.gif">&nbsp;</td>

	<td height="30" width="130" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_bg.gif"><a href="index.php" class="top-menu-title">Catalogue</a></td>

	<td height="30" width="1" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_delim.gif">&nbsp;</td>	

	<td height="30" width="130" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_bg.gif"><a href="index.php?act=viewDoc&docId=6" class="top-menu-title">Portfolio</a></td>

	<td height="30" width="1" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_delim.gif">&nbsp;</td>

	<td height="30" width="130" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_bg.gif"><a href="index.php?act=account" class="top-menu-title">My Account</a></td>

	<td height="30" width="1" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_delim.gif">&nbsp;</td>

	<td height="30" width="130" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_bg.gif"><a href="cart.php?act=step2" class="top-menu-title">View Cart</a></td>

	<td height="30" width="1" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_delim.gif">&nbsp;</td>

	<td height="30" align="center" background="skins/{VAL_SKIN}/styleImages/menu-bar/top_menu_bg.gif">&nbsp;</td>					

	</tr>

</table>	

<table width="100%" border="0" cellspacing="0" cellpadding="0">	

	<tr width="100%" background color="#DCDCDC"><td height="10" align="center" ></td></tr>	

</table>	

<!-- End Top Menu -->



   </td>

  </tr>

</table>

<!-- End Header Table -->



<!-- Start Sidebox + MainBox Table -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

	<td><table width="100%" border="0" cellspacing="0" cellpadding="0">

	  <tr>



<!-- Start Sideboxes -->

		<td style="padding-left: 10px; padding-top: 0px;"width="185" valign="top">

		{CATEGORIES}

		{SESSION}

		{SHOPPING_CART}

		{RANDOM_PROD}

			{SITE_DOCS2}

		{SPONSOR1}

		{ADSENSE}

		{MAIL_LIST}

		</td>

<!-- End Sideboxes -->



<!-- Start MainBoxes -->

		<td class="colMid" valign="top">{PAGE_CONTENT}</td>

<!-- End MainBoxes -->

		

	  </tr>

	</table></td>

  </tr>

</table>

<!-- End Sidebox + MainBox Table -->



<!-- Start Footer Table -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">

	<!-- Start Footer Images -->

	<tr width="100%"><td height="15" align="center" background="skins/{VAL_SKIN}/styleImages/header/top_menu_bg.gif"></td></tr>

	<!-- End Footer Images -->

</table>

<div class="txtCopyright">All Content Copyright <a href="http://www.semperfiphotography.com">SemperFi Photography </a>2006. All rights reserved.</div>

<!-- End Footer Table -->

</body>

</html>

<!-- END: body -->




styleTemplates/content/portfolio.tpl


<!-- BEGIN: portfolio -->

<!-- Start Portfolio -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

	<td class="boxContentTitleLeft">&nbsp;&nbsp;{HOME_TITLE}</td>

	<td class="boxContentTitleCenter">&nbsp;</td>

	<td class="boxContentTitleRight">&nbsp;</td>

  </tr>

</table>



<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

	<td class="boxContent">Test</td>

  </tr>

</table>



<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

	<td class="boxContentFooterLeft">&nbsp;</td>

	<td class="boxContentFooterCenter">&nbsp;</td>

	<td class="boxContentFooterRight">&nbsp;</td>

  </tr>

</table>

<!-- End Portfolio -->



<br>



<!-- END: portfolio -->

But I am getting this error message :

Fatal error: Call to a member function on a non-object in /home/semperfi/public_html/includes/content/portfolio.inc.php on line 49

What have I missed?

TIA :)

Link to comment
Share on other sites

Guest efolia

But I am getting this error message :

Fatal error: Call to a member function on a non-object in /home/semperfi/public_html/includes/content/portfolio.inc.php on line 49

What have I missed?

TIA ;)

the error is quite explicit: $portfolio is not an object ;-)

(hint: $index is)

Link to comment
Share on other sites

Guest EverythingWeb

Why dont, instead of recreating a complete new php call page, why not add another action flag onto the array thats already there;

case "portfolio":

include("includes/content/portfolio.inc.php");

$body->assign("PAGE_CONTENT",$page_content);

break;

Then calling it, is as simple as; index.php?act=portfolio

Link to comment
Share on other sites

Guest efolia

Thanks for the reply efolia :w00t:

So what do I need to do and where to correct it?

You defined your object as $index, but you're trying to parse an (inexistant) object pointed at by a variable named $portfolio. Change that reference to $index.

I think you are confusing the template file name with the object itself. The template file (portfolio.tpl) is only used by your instanciated object for formatting purposes.

EDIT: I forgot to mention that if you're gonna use $index as your object reference, you have to rename it in the tpl too (in the BEGIN and END statements). Or you can change $index to $portfolio in the .php file if you prefer, thus leaving the template as is.

Cheers.

Link to comment
Share on other sites

You defined your object as $index, but you're trying to parse an (inexistant) object pointed at by a variable named $portfolio. Change that reference to $index.

Thats precisely what I had wrong.

Amazing what a fresh set of eyes will do.

Thankyou :w00t:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...