Jump to content
daerias

[HannaCode] (PW+ZF5) no header image

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!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thank you so much it works fine! :)  :rolleyes: but I don't understand why should I use ?> before php-hannacodes?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • 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.
       
    • By msavard
      I have a situation where I have links to a bunch of forms on my site. Every year the links to the forms change slightly, adding the current year to the end. So it is something like http://www/somewhere.com/form1/2017. Next year it will be the same thing but with 2018 in the URL.
      I was hoping HannaCode could help me out here by letting me create a snippet that would read the year from a settings page and insert that at the end of any links I specify. So in the CKEditor I create a link, add [[cyr]] (my HannaCode snippet that pulls back the year from the settings page and I verified that it is indeed working properly) to the end and instead of pulling in the year it is just encoding the [[cyr]] into the URL. I was expecting
      http://www.somewhere.com/form1/2017  and I'm getting
      http://www.somewhere.com/form1/%5b%5bcyr%5d%5d .
      Is HannaCode not able to work with raw HTML this way? Is there some other way to do what I'm trying to accomplish? I really don't want to go around the site updating 100 links when a new year comes around.
      All the links are to forms on an external site in case that helps...
      Thanks.
    • By joeck
      Hello everyone,
      My Website works just fine beside the one field which behaves strangely and I can't figure out why.
      I have a template called "main-subpage" which I use for most subpages. All of them have a header and on every other Page it works just fine.
      But on the one page it displays the first few letters random and sometimes the last ones corectly, sometimes the last ones are wrong as well. What iritates me is that this is only on the one Page and all the other pages with the same template don't have that issue. The rest of the page is displayed just fine.
      I tried different content in the field but it doesnt seem to help anything.
       
      Code in the template:
      <h1> <?php echo $page->header | $page->title; ?> </h1> on the page it should display: "Das Konzept des ZiSMed" but what I see is (attachement):
       
      Thank you for your help!
      display.tiff
×
×
  • Create New...