parse error on script

A

Anonymous

Guest
its been a while since i used php so this is probably very obvious. i'm trying to use php to check the value of a function result and then output html accordingly. here's the code:

Code:
<?php if (mosCountModules('frontimage') > 0) {
$layout ='<div id="frontimage"><?php mosLoadModules('frontimage', -1 );?></div><div id="lead_back"><img src="/templates/PCGMambo/images/mouse.png" /></div><div id="lead_story"><?php mosLoadModules ( 'right',-1 ); ?></div>';
}
elseif (mosCountModules('frontimage') == 0){
$layout = '<div id="mainbody"><?php mosMainBody(); ?></div>';
}
?>



<div id="lead_back"><img src="/templates/PCGMambo/images/mouse.png" /></div>
<?php echo $layout ?>

i get a parse error for the first line which sets the $layout variable. can anyone tell me what is causing this?

many thanks,

lukemack.
 
It would be helpful if you could post the exact error message, but I see some potential trouble, here.

In your $layout line, are you just trying to put the value that mosLoadModules() returns into the string? If so, none of that <?php ?> stuff is necessary. Just do like so:

Code:
$layout = '<div id="frontimage">' .
             mosLoadModules('frontimage', -1 ) .
          '</div>' .
          '<div id="lead_back">' .
             '<img src="/templates/PCGMambo/images/mouse.png" />' .
          '</div>' .
          '<div id="lead_story">' .
             mosLoadModules ('right', -1 ) .
          '</div>';

P.S. See how much a little whitespace can help make your code more readable...
 
that kind of works but the divs dont contain the results of the functions (they insert text and a picture)

the content appears on the page but is not placed within the div tags:

here's the code i'm using:

Code:
<?php if (mosCountModules('frontimage')==1 ){

$layout='<div id="frontimage">' .
             mosLoadModules('frontimage', -1 ) .
          '</div>' .
          '<div id="lead_back">' .
             '<img src="/templates/PCGMambo/images/mouse.png" />' .
          '</div>' .
          '<div id="lead_story">' .
             mosLoadModules ('right', -1 ) .
          '</div>';
}
else if (mosCountModules('frontimage' !=1)){
$layout='<div id="mainbody">' .
             mosMainBody() .
            '</div>';
}
echo $layout;
?>

how can i make the content actually occur within the div tags within the html sent to the browser? at the moment, the content called by the functions is sent to the browser, followed a series of empty divs (the ones in the code above) so the layout is all wrong.

thanks,

lukemack.
 
in your mosMainBody()
you do...
Code:
echo ''..the content..";
 
sorry i dont know what you mean. mosMainBody() returns content so i dont want to add any more. i just want the result of mosMainBody() to appear between the divs.
 
Back
Top