Jump to content

[HannaCode] (PW+ZF5) no header image


daerias
 Share

Recommended Posts

Hi Community :)

I have a little problem:

I have PW+ZurbFoundation5 with HannaCode-module

my home.php:

<!doctype html>
<html class="no-js" lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
    <link rel="stylesheet" href="<?php echo $config->urls->templates; ?>css/foundation.css" />
    <script src="<?php echo $config->urls->templates; ?>js/vendor/modernizr.js"></script>
  </head>
  <body>
  
<!-- HannaCode -->
<?php $body = $page->body; echo $page->body; ?>

    
    <script src="<?php echo $config->urls->templates; ?>js/vendor/jquery.js"></script>
    <script src="<?php echo $config->urls->templates; ?>js/foundation.min.js"></script>
    <script>
      $(document).foundation();
    </script>
  </body>
</html>

HannaCode [[bigheader]] as HTML:

<div class="row fullWidth img">
  	<img src="<?php echo $config->urls->templates; ?>img/header.jpg" alt="header-picture">
</div>

and my Page with body field:

[[bigheader]]

and this is the rendered page:

CGzaiLB.png

what is wrong with my code? Thanks!

Link to comment
Share on other sites

Seems like you've chosen the wrong type of hanna code. It contains php, so you need to choose php as type not html. Html code will be plain inserted and not compiled by php, that's why it's landing directly in the source code. 

A small thing I noticed.

// why the $body variable if you're not using it?
<?php $body = $page->body; echo $page->body; ?> 

// this does the same thing
<?php echo $page->body; ?>
  • Like 2
Link to comment
Share on other sites

thanks LostKobraki ;)

I have changed my hannacode to PHP and changed the code:

<?php <div class="row fullWidth img">
  	<img src="<?php echo $config->urls->templates; ?>img/header.jpg" alt="header-picture">
</div> ?>

after this I have:

KCSn9cv.png

Link to comment
Share on other sites

You need to echo the html markup within your outer php tags as strings. Or you can probably just get rid of the outer php tags.


<?php

echo '<div class="row fullWidth img">';

echo ' <img src="' . $config->urls->templates . 'img/header.jpg" alt="header-picture">';

echo '</div>';

?>

<!-- OR simply: -->

?> //just a closing tag here

<div class="row fullWidth img">

<img src="<?php echo $config->urls->templates; ?>img/header.jpg" alt="header-picture">

</div>

  • Like 2
Link to comment
Share on other sites

You need to echo the html markup within your outer php tags as strings. Or you can probably just get rid of the outer php tags.

<?php
    echo '<div class="row fullWidth img">';
    echo '  	<img src="' . $config->urls->templates . 'img/header.jpg" alt="header-picture">';
    echo '</div>';
?>

Thanks Sr. Member it works with the first solution with echo but the second soulution doesn't

is there any way to do this without echo, because it could be borring if I have a lot of lines?

Link to comment
Share on other sites

Your code is probably implemented into another php file so this would look something like this:

<?php 

  // Modules include

  <div class="…"><!-- Your HTML --></div>

This would cause an error without the closing ?> and it would makes sense not to expect everybody to open a php hanna code with <?php .

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...