Jump to content

Recommended Posts

Posted

I am experimenting with making a new template, and managed to set up a working Planets template a la Ryan Cramer's discussion at https://processwire.com/docs/tutorials/hello-worlds/

However, I have tried to get this to work with my own code, but get an XML parsing error:

Quote

XML Parsing Error: junk after document element
...
Line Number 12, Column 8:</html><!DOCTYPE html>
-------^

<html>
  <head>
    <title><?php echo $page->title; ?></title>
  </head>
  <body>
    <h1><?php echo $page->person_name; ?></h1>
    <h2>Manuscript: <?php echo $page->library; ?></h2> 
    <p><?php echo $page->manuscript; ?></p>
    <p>Reference <?php echo $page->reference; ?></p>
    <p><?php echo $page->note; ?></p>
    </body>
</html>

There's no white space at the end of my code. I thought it could be something wrong with the processwire code, but the Planets example worked for me. I have checked, and tripple-checked my field names. Any thoughts?

Posted

Welcome to the forums, @michaelriordan!

It is all there in the error message. Something gets added to the file you are writing you markup in (<!DOCTYPE html> in particular) . It seems like you have started with a profile that uses delayed output. And the contents of _main.php are appended after your code.

You can check site/config.php if it contains something like $config->appendTemplateFile = '_main.php'; to make sure.

Start with a blank or beginner profile instead.

If that did not help please provide more details.

  • Like 1
Posted

Thanks. I get the idea now. I've read the delayed output article. But still no idea how to get custom fields to output. I want delayed output, because I want header, footer and sidebar to display

I've tried the following, with and without the 'get()' in $page->get()", and it only displays the person_name field:

<?php

$headline = $page->get("title");
$bodycopy = "<h1>" . $page->get("person_name") . "</h1><h2>Manuscript: " . $page->get("library") . "</h2><p>" . $page->get("manuscript") . "</p><p>Reference" . $page->get("reference") . "</p><p>" . $page->get("note") . "</p>";
$sidebar = $page->sidebar;
include("./main.inc");

 

Here's an example of the output: https://michaelriordan.hostiso.host/p/gilbert-burnet/ "Gilbert Burnet" is person_name...  The file source has:

<div id='content'>
			<h1>Gilbert Burnet</h1>
					</div>

I must be misunderstanding something here. Why does $bodycopy give up after finding the first field....

Posted

Hey man! We all here will do our best to help you, but you should provide at least some details) Like what profile did you install and started from.

It just might be that you do use the default profile, and the the name of the variable for main content should be $content and not $bodycopy. But that is a just a wild guess. Be more specific, provide some details and get the best answers on the web from the most awesome community on the planet:-[. Have fun with ProcessWire!

  • Like 3
Posted

I get the feeling that the Gilbert Burnett you are seeing is actually the $headline.

I bet that $bodycopy is not being output/echo'd within main.inc at all.

  • Like 1
Posted

Thanks -- Ah, I see why I confused $content and $bodycopy ... $content worked perfectly. I think I started with the blank processwire profile, but not sure how I would find this... I'll keep learning... everything's working fine for now though.

  • 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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...