By flanderz on
I'm trying to programtically create error pages in my installation profile. If you don't know profiles, don't worry, just pretend I'm doing this in a module. (It's really a PHP question.)
Here's my PHP
// setup error pages
include('include/404_error.php');
$nid = db_next_id('{node}_nid');
$vid = db_next_id('{node_revisions}_vid');
$node_sql = "INSERT INTO {node} (nid, vid, type, title, status, created, comment) VALUES (%d, %d, '%s', '%s', %d, %d, %d)";
db_query($node_sql, $nid, $vid, 'page', 'MadMariner: Error: Not Found', 1, time(), 0);
$rev_sql = "INSERT INTO {node_revisions} (nid, vid, title, body, timestamp, format) VALUES (%d, %d, '%s', '%s', %d, %d)";
db_query($rev_sql, $nid, $vid, 'MadMariner: Error: Not Found', $error_404, time(), 2);
And now here's the include stuff (simplified for ease of reading.)
$error_404 = <<<END
<?php $path_to_theme = "/" . drupal_get_path("theme", "madmariner"); ?>
<img src="<?php print $path_to_theme; ?>/images/error_404_header.png" alt="" />
END;
Unfortunately this just gets output onto the screen, instead of populating the large string. So what I'm really after is how to set a really long string, ideally using an include so as to not clutter my file. Any ideas?
TIA,
flanderz
Comments
Trying to create a page using db_query
I'm not a PHP whiz, so take it with a grain of salt, but I've never seen the
<<</END...ENDsyntax before (and searching the PHP manual doesn't show anything like it). Have you tried enclosing your string in single quotes? The only difficulty is if there are single quotes in your string, which would then need to be escaped. Quoted strings can be pretty long--I don't think that will limit you.phen
Looks like you're calling
Looks like you're calling functions in a heredoc variable. I don't think that works. Use curly braces for an array or an object. You could assign a function to some variable to reuse, if it returns a value and not echos. Or try a scratch pad -
http://us2.php.net/manual/en/language.types.string.php#language.types.st...