How to insert code above !DOCTYPE statement?

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
mstroz
Posts: 53
Joined: Wed 13. Apr 2005, 18:38
Location: Macon, Georgia USA
Contact:

How to insert code above !DOCTYPE statement?

Post by mstroz »

I need to insert this:

Code: Select all

<?
if (isset($_GET['status']))
{
	$status = $_GET['status'];
}
?>
conditional statement above the head tag, and even above the !DOCTYPE statement.

How? Is this even possible?

Thanks,
Mark
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

Sounds like something for frontend_init -or- frontend_render.
Check the samples in "/phpwcms_template/inc_script/" -or- "/phpwcms_code_snippets/FE_Login/"
mstroz
Posts: 53
Joined: Wed 13. Apr 2005, 18:38
Location: Macon, Georgia USA
Contact:

Post by mstroz »

Actually I just found it in on line #154 in index.php

The problem is I can't get the syntax right when I try to add my statement.

Take a look...

Code: Select all

->	$content['page_start'] = '<?';
my	$content['page_start'].= 'if (isset($_GET['status']))';
code	$content['page_start'].= '{';
here	$content['page_start'].= '$status = $_GET['status'];';
	$content['page_start'].= '}';
->	$content['page_start'].= '?>';
	$content['page_start'] .= '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
	$content['page_start'] .= "\n<!--\n     phpwcms | free open source content management system\n";
	$content['page_start'] .= "     created by Oliver Georgi (oliver at phpwcms dot de) and licensed under 

GNU/GPL.\n";
	$content['page_start'] .= "     phpwcms is copyright 2003-2005 of Oliver Georgi. Extensions are 

copyright of\n";
	$content['page_start'] .= "     their respective owners. Visit project page http://www.phpwcms.org for 

details.\n//-->\n";
	$content['page_start'] .= "<html>\n<head>\n<title>".$content["pagetitle"]."</title>\n";
	$content['page_start'] .= '<meta http-equiv="Content-Type" content="text/html; charset=';
	$content['page_start'] .= PHPWCMS_CHARSET."\">\n".'<script src="'.TEMPLATE_PATH;
	$content['page_start'] .= 'inc_js/frontend.js" type="text/javascript"></script>'."\n";
	$content['page_start'] .= '<link rel="stylesheet" type="text/css" href="'.TEMPLATE_PATH;
	$content['page_start'] .= "inc_css/".$block["css"]."\" />\n".$block["htmlhead"];
	$content['page_start'] .= "\n</head>\n\n<body".$content["body"].">\n";
I delineated my code addition with a "->", it's at the top over the !DOCTYPE statement.

Anyway. I keep getting a parse error. I think it has something to do with the opening <? tag.
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

mstroz wrote:Anyway. I keep getting a parse error. I think it has something to do with the opening <? tag.
Nope, you forgot to escape quotes:

Code: Select all

$content['page_start'] = '<?';
$content['page_start'].= 'if (isset($_GET[\'status\']))';
$content['page_start'].= '{';
$content['page_start'].= '$status = $_GET[\'status\'];';
$content['page_start'].= '}';
$content['page_start'].= '?>';
I'm not sure what your aim is, but PHP is only going to "interpret" PHP code ~once~ as "index.php" is run through. The $content['page_start'] is building a page that the ~browser~ will have to "interpret". When the end of "index.php" is reached... PHP is no longer in the picture and did ~not~ "execute" your snippet. I thnk the string is merely passed to the browser and discarded (as it's looking for the !DOCTYPE first).
mstroz
Posts: 53
Joined: Wed 13. Apr 2005, 18:38
Location: Macon, Georgia USA
Contact:

Post by mstroz »

Nope, you forgot to escape quotes:
Ah. Thanks. I'm a bit of a PHP 'tard.
I'm not sure what your aim is...
The top tab nav (a Flash component) on the secondary level pages passes a variable (when clicked) to the Flash Header on the homepage.

Someone told me the statement needed to be at the top of the page, above the head tag, and even above the DOCTYPE.

By the way, I really appreciate all the help you've been giving me.
Post Reply