Jump to content

why can't see header?

Recommended Posts

Do you mean in your template file? If so, you can do:

<img src="<?php echo $page->header->url; ?>" alt="<?php echo $page->header->description; ?>" />

This will get the url of the header image and allow you to out put the image for the page.

Share this post

Link to post
Share on other sites

result :


Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Error has been logged.

Share this post

Link to post
Share on other sites

Could you show an example of your template file where you are trying to output the header image? Also, is you "header" field set to single image or multiple images? If multiple, the example I gave will not work.

Share this post

Link to post
Share on other sites

<?php namespace ProcessWire;

// basic-page.php template file 

// Primary content is the page's body copy
$content = $page->body; 

// If the page has children, then render navigation to them under the body.
// See the _func.php for the renderNav example function.
if($page->hasChildren) {
    $content .= renderNav($page->children);

// if the rootParent (section) page has more than 1 child, then render 
// section navigation in the sidebar (see _func.php for renderNavTree).
if($page->rootParent->hasChildren > 1) {
    $sidebar = renderNavTree($page->rootParent, 3); 
    // make any sidebar text appear after navigation
    $sidebar .= $page->sidebar; 

Share this post

Link to post
Share on other sites

Go to the tab "Details", under "Maximum files allowed" enter 1.

Go to the tab "Actions" and assure to have ticked the checkbox of the template you want to have the header image in.

Share this post

Link to post
Share on other sites

In the code fragment you showed of your template file there is no output of the image (like @louisstephens proposed).

Without more information it is hard to help.

Share this post

Link to post
Share on other sites

Turn on $config->debug in your site/config.php, then you get a better error message, that says what the problem is.

Look under details of your image field and then "formatted value". Is it set to automatic?

Is "Maximum files allowed" set to 0?

If so, try 


<img src="<?php echo $page->header->first()->url; ?>" alt="<?php echo $page->header->first()->description; ?>" />

That is because an array is returned if "Maximum files  allowed" is 0.

Share this post

Link to post
Share on other sites
On 5/13/2019 at 8:35 PM, wish-fulfillment said:

// Primary content is the page's body copy
$content = $page->body; 

There are roughly three types of ("official") templating strategies in PW:

  • Direct output (php echo everything immediately)
  • Delayed output (what you seem to be using, i.e. output var $content just once)
  • Markup regions
22 minutes ago, jens.martsch said:

<img src="<?php echo $page->header->first()->url; ?>" alt="<?php echo $page->header->first()->description; ?>" />


If you really are using delayed output, you would have to rewrite this, e.g. like

$src = $page->header->first()->url;
$alt = $page->header->first()->description;
$content .= "<img src=\"$src\" alt=\"$alt\" />

Your header most likely comes before the main content (body), so you just have to figure out where to insert the above code. It may not be in the basic-page template file, but somewhere else. Note that $var = 'foo' will override anything else that came before, i.e. if you defined $content = 'your-header-code' before, $page->body will completely reset your $content variable, not append to it.

On 5/13/2019 at 8:35 PM, wish-fulfillment said:

$content = $page->body; 


Share this post

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

  • 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!

    • 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 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!
    • By ridgedale
      I need to separate the header, footer and sidebar from the _main.php file.
      I've tried all of the following without success:
      <?php include ("header.php"); ?> <?php include ("/_header.php"); ?> <?php include ("./header.inc"); ?> <?php $header = pages()->get('/rcl-header.php'); // include header echo $header; ?> Any guidance would be appreciated.
    • By suntrop
      The last days two new sites went online and both got a SSL certificate installed.
      But one has a HTTP problem, although both are configured the same (seem to be). When I run 
      curl -I -L https://www.example.com/
      it gets redirected to itself again and again. I had a HTTPS redirect in my .htaaccess but have removed it. The home template was configured to use only HTTPS but is now configured to accept both. If I change that to HTTP only, I get and error.
      The origin must come from PW, because all files not processed by PW don't have the redirect problem.
      I had a look at the /site/assets/cache/ folder but don't know what to delete. And there is a cache table in the DB as well. Don't know either if I can just delete its entries.
      Apache 2.4.18 
      PHP 7.0.11
      PW 3.0.42
      No dedicated cache installed, no cache activated in PW
  • Create New...