PDA

View Full Version : placing php code within define?



Resshin
October 18th, 2006, 01:48
Hi there.
I want to edit a OsCommerce index.php file so that I can use FusionNews to post updates instead of having to edit index.php everytime.

The problem is that I don't know where to add the code. When I add the code to the file, the post box will appear at the top of the page, which is not where I need it.

So i noticeted that the code

define('TEXT_MAIN','');
is where I should put stuff so that the text appears in the body of the page. I can't seem to put the FusionNews code there..this is what I tried

define('TEXT_MAIN','include '/home/resshin/public_html/news/news.php';')

btw this is the entire code of the file i'm trying to edit

<?php
/*
$Id: index.php,v 1.1 2003/06/11 17:38:00 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

define('TEXT_MAIN', '');
define('TABLE_HEADING_NEW_PRODUCTS', 'New Products For %s');
define('TABLE_HEADING_UPCOMING_PRODUCTS', 'Upcoming Products');
define('TABLE_HEADING_DATE_EXPECTED', 'Date Expected');


if ( ($category_depth == 'products') || (isset($HTTP_GET_VARS['manufacturers_id'])) ) {
define('HEADING_TITLE', 'Let\'s See What We Have Here');
define('TABLE_HEADING_IMAGE', '');
define('TABLE_HEADING_MODEL', 'Model');
define('TABLE_HEADING_PRODUCTS', 'Product Name');
define('TABLE_HEADING_MANUFACTURER', 'Manufacturer');
define('TABLE_HEADING_QUANTITY', 'Quantity');
define('TABLE_HEADING_PRICE', 'Price');
define('TABLE_HEADING_WEIGHT', 'Weight');
define('TABLE_HEADING_BUY_NOW', 'Buy Now');
define('TEXT_NO_PRODUCTS', 'There are no products to list in this category.');
define('TEXT_NO_PRODUCTS2', 'There is no product available from this manufacturer.');
define('TEXT_NUMBER_OF_PRODUCTS', 'Number of Products: ');
define('TEXT_SHOW', '<b>Show:</b>');
define('TEXT_BUY', 'Buy 1 \'');
define('TEXT_NOW', '\' now');
define('TEXT_ALL_CATEGORIES', 'All Categories');
define('TEXT_ALL_MANUFACTURERS', 'All Manufacturers');
} elseif ($category_depth == 'top') {
define('HEADING_TITLE', 'What\'s New Here?');
} elseif ($category_depth == 'nested') {
define('HEADING_TITLE', 'Categories');
}
?>

that did not work lol....

so i was wondering if anyone can help me...btw, if you havne't noticed, I have no clue how php works...and I probably should post this in the oscommerce support forums...but i haven't got much help from users there in the past

stuffradio
October 18th, 2006, 01:59
Try


define('TEXT_MAIN','include "/home/resshin/public_html/news/news.php";');

or


define('TEXT_MAIN','include '/home/resshin/public_html/news/news.php';');

Resshin
October 18th, 2006, 02:09
hi, thanks for the help

i tried both codes..the first one resulted in
include /home/resshin/public_html/news/news.php showing up on the main page

while the second one gave a

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/resshin/public_html/store/includes/languages/english/index.php on line 13

stuffradio
October 18th, 2006, 02:12
k, try



define('TEXT_MAIN','include /home/resshin/public_html/news/news.php;');

Resshin
October 18th, 2006, 02:28
hi, thanks again.

this one had the same result as the first one...displaying include /home/resshin/public_html/news/news.php on the main page..

Fried
October 18th, 2006, 02:35
Actully, it resulted in displaying news.php on the main page because that's what your defining it to do... That's why it's called TEXT_MAIN, as in main page.

Resshin
October 18th, 2006, 02:41
right now it is showing the text of "/home/resshin/public_html/news/news.php"

I want it to show the contents of news.php on the main page.

thanks

influct
October 18th, 2006, 03:56
define('TEXT_MAIN','include("/home/resshin/public_html/news/news.php");')
try that...

krakjoe
October 18th, 2006, 03:57
you could try



ob_start();
include "/home/resshin/public_html/news/news.php";
$news= ob_get_contents();
ob_end_clean();
define( 'TEXT_MAIN', $news );


that might work....

Resshin
October 18th, 2006, 10:46
you could try



ob_start();
include "/home/resshin/public_html/news/news.php";
$news= ob_get_contents();
ob_end_clean();
define( 'TEXT_MAIN', $news );


that might work.... :God:

thank you! this worked!

thanks to everyone else for their efforts! :D

krakjoe
October 18th, 2006, 11:58
thought it would, but I never used the script you're on about so didn't wanna say it would for sure ....