wish-fulfillment Posted May 13, 2019 Share Posted May 13, 2019 Link to comment Share on other sites More sharing options...
louisstephens Posted May 13, 2019 Share Posted May 13, 2019 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. Link to comment Share on other sites More sharing options...
wish-fulfillment Posted May 13, 2019 Author Share Posted May 13, 2019 should i insert this code every timt? I thought it's done automatically Link to comment Share on other sites More sharing options...
wish-fulfillment Posted May 13, 2019 Author Share Posted May 13, 2019 result : Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Error has been logged. Link to comment Share on other sites More sharing options...
louisstephens Posted May 13, 2019 Share Posted May 13, 2019 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. Link to comment Share on other sites More sharing options...
wish-fulfillment Posted May 13, 2019 Author Share Posted May 13, 2019 <?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; } Link to comment Share on other sites More sharing options...
wish-fulfillment Posted May 13, 2019 Author Share Posted May 13, 2019 "header" field set to single image - where to do it? Link to comment Share on other sites More sharing options...
wish-fulfillment Posted May 14, 2019 Author Share Posted May 14, 2019 Link to comment Share on other sites More sharing options...
wish-fulfillment Posted May 14, 2019 Author Share Posted May 14, 2019 Any kind of help will be much appreciated. Link to comment Share on other sites More sharing options...
ottogal Posted May 14, 2019 Share Posted May 14, 2019 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. Link to comment Share on other sites More sharing options...
wish-fulfillment Posted May 14, 2019 Author Share Posted May 14, 2019 Danke, ich machte es, aber vergebens Link to comment Share on other sites More sharing options...
ottogal Posted May 14, 2019 Share Posted May 14, 2019 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. Link to comment Share on other sites More sharing options...
dotnetic Posted May 15, 2019 Share Posted May 15, 2019 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. Link to comment Share on other sites More sharing options...
dragan Posted May 15, 2019 Share Posted May 15, 2019 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; Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now