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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By fruid
      I'm trying to pass a variable from one hannacode occurence to the next.
      hannacode: [[nextimage]]
      if (isset($next)) : $next++; else: $next=0; endif; $nextimage = $page->images->eq($next); echo '<img title="'.$nextimage->title.'" alt="'.$nextimage->title.'" src="'.$nextimage->url.'"/>'; But everytime the hannacode runs, it's a different scope so to say.
      Any ideas?
    • By Greg Lumley
      Hi, this has me stumped, please help. 😳

      I'm using a field 'page_body' in a page-template as well as a blog-template. 
      HannaCodeDialogue is enabled for the field page_body.
      HannaCode works perfectly in Pages but not in Posts. 

      The dropdown is visible in the pages edit template but not in the posts edit template. 
      If I manually put the code into the Posts Template i.e. : [[YouTubeVideo videoName="my_vid"]] it simply displays the tag. 
      I'm quite sure this is a config error of some sort but for the life of me, I can't find it. 
       
      Thank you. 
       
      Greg. 
    • By Mithlesh
      Hi, I have one URL - writerrelocations.com/contact-now/

      I have one issue where my header Image is appearing again after the contact form, for your reference:



      I have checked my processwire template section where have not added any Image field besides Header Image, attaching the same for the reference:




      PLEASE help me to get rid of the image below contact form

      Waiting for the swift response!

      Thanks
       
    • By dragan
      I'm puzzled by something I thought would be rather easy:
      I want to send a request to a PW page. It's POST, and I define a header, and send data as JSON.
      I need to send data in the following format:
      $ POST https://mysite.com/foo/bar/ {"headers": {"Authorization": "Bearer API_KEY", "Content-Type": "application/json"}, "body": {"fields": {"Name": "<get name>", "Department": "<get team>", "Home Address": "<get address>", "Phone #": "<get phone>", "Personal Email Address": "<get email>", "Birthday": "<get birthday>", "Date Added": "<call>currentDate</call>" }}} This is supposed to be sent via a Chatbot engine (Dexter).
      In the PW page that should handle this, $_POST is always empty, as is $_REQUEST. Same for PW's $input or if ($config->ajax) {}.
      I get the header, but no data.
      So I dug deeper, and tried this:
      @ini_set("allow_url_fopen", true);
      @ini_set("always_populate_raw_post_data", true);
      $data = json_decode(file_get_contents('php://input'), true);
      $d    = print_r($data, true); // I store this, along with the header infos and timestamp in a PW page-field (instead of using file_put_content)
      I checked page permissions, I made sure I use pagename/, i.e. with trailing slash only, to avoid stripping the header away due to redirects (which somebody in an older forum thread once highly suggested).
      I tried to send the same stuff that the chatbot does via CURL. Nothing. PW error logs don't report anything (site is still in dev-mode).
      PW 3.0.81 - everything else runs just fine.
      Any ideas what I should change? Any more PHP/Apache settings maybe?
      Help is highly appreciated.
       
×
×
  • Create New...