Jump to content

Recommended Posts

Posted

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!

Posted

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
Posted

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

Posted

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
Posted

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?

Posted

I updated my post above. Apparently you need a closing php tag at the top, so it doesn’t expect php code.

Disclaimer: I have only tested this with a PW and module version from about a year ago.

  • Like 1
Posted

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

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
×
×
  • Create New...