Hi,
So, first question...
To learn how to use PW, I tried to build a really basic news system. So I created a news template with 4 fields - title, date, summary, image. Done.
After, as I was not sure I started from basic-page.php and tried to modify by using HTML from my old website. After many trials and errors, I succeed to display something.
<?php namespace ProcessWire;
$content = "<article><h2>" . $page->body . "</h2>
<header class='news-meta'>
<strong>Date : </strong> " . $page->get("publish_date") . "
</header>
<div class='news-content-text'>
<p>". $page->get("summary") . "</p>
</div>
<div class='article'> text </div>
" . "<p><img src='" . $image->url."' alt='". $image->description . "' ></p> </article>"; //image doesn't work!!
// 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;
}
So my questions :
I don't like it, way too much concatenation and I'm lost between " and '. How I should do that?
Why this template is not similar to main.php with a part in php and one in html? In fact, my problem is that I'm not sure how to mix them
Why page->body doesn't throw all fields of the template? More specifically, what is it? I can't find it in the cheatsheet...
Why basic-template.php have an open <? php but any closing bracket?
Thanks!!
Mélanie