Jump to content

Tutorial problem


NoDice
 Share

Recommended Posts

Hi, I just tried to run through the Basic Website Tutorial found here:
 
 
When I got to the first testing under section “Testing the layout with the Home page”, I ran into some problems and the edited homepage did not render properly. Instead I get two error messages (with  “# Time Memory Function”-tables with values in between). 
 
The error messages are (same in both places):
 
Notice: Undefined variable: has_children in C:\wamp\www\XXXX\site\templates\TUT_topnav.inc on line 37
 
Line 37 in the TUT_topnav.inc is: 
if($has_children && $child !== $root) {
 
I may have made some rookie error, of course, but before looking for that I wanted to check with you if there may be something that prevents my versions of some component from understanding the has_children variable?
 
Don’t think I have done anything to define it in the code I put in/edited (but naturally that does not mean I’m not responsible for some newbie-dumbassery here). 
 
Any thoughts on this? 
 
Link to comment
Share on other sites

 
Line 37 in the TUT_topnav.inc is: 
if($has_children && $child !== $root) {
 

 

I think that's must be mistake in the tutorial. You can replace $has_children with $child->numChildren()

 

if($child->numChildren() && $child !== $root) {
 

There is discussion about to check if given page has children http://processwire.com/talk/topic/3527-check-if-a-given-page-has-children/

 

Link to comment
Share on other sites

 

 

I think that's must be mistake in the tutorial. You can replace $has_children with $child->numChildren()

 

if($child->numChildren() && $child !== $root) {
 

There is discussion about to check if given page has children http://processwire.com/talk/topic/3527-check-if-a-given-page-has-children/

Thanks for the prompt reply! Unfortunately, that left me with the same number of errors and the same result in output, only the message now is:

Notice: Undefined variable: onlyViewable in C:\wamp\www\tendfor\wire\core\Page.php on line 807
 

As there are close to 12,000 views on that tutorial, I am kind of leaning towards either me having messed up, or me having the wrong version of some component. Kind of reluctant to start changing things in tons of files/places since it appears to have worked for everyone else. 

Link to comment
Share on other sites

That must be an error in the tutorial, since that variable appears only in that line. I looked on google for this code, and it appears to be from here http://processwire.com/talk/topic/2787-custom-menu-not-related-to-page-tree/, and the missing line would be this one:

$has_children = count($child->children('include=all')) ? true : false;
  • Like 3
Link to comment
Share on other sites

I've changed the tutorial, adding that line. Joss was creating that wiki page, but he's been a bit scarce lately.

@NoDice try making that change and report back if it works or not, please. It will be very helpful to get some feedback on that tutorial.

  • Like 2
Link to comment
Share on other sites

I've changed the tutorial, adding that line. Joss was creating that wiki page, but he's been a bit scarce lately.

@NoDice try making that change and report back if it works or not, please. It will be very helpful to get some feedback on that tutorial.

Thanks team - amazingly quick with the solution - that did the trick (used the new TUTtopnav.inc code from the tutorial page)! Will report back after finishing the whole thing and let you know if I run into something else. About to have dinner with some friends here in the Stockholm Archipelago, so won't be until tomorrow. 

//ND

  • Like 1
Link to comment
Share on other sites

I've changed the tutorial, adding that line. Joss was creating that wiki page, but he's been a bit scarce lately.

@NoDice try making that change and report back if it works or not, please. It will be very helpful to get some feedback on that tutorial.

OK, here are a few more points to consider Dave:
 
  • The “clearfix” class comes and goes (there in initial TUT_article.php code under section “Template File” as a class for article_maintext; but no longer present in the resulting example under section “Adding the Fields”). It is part of the CCS so should be in the HTML I think, as it is needed for the layout to work as intended. Hence, it should be in the latter example of finished code as well to avoid confusion. 
  • When the fields are defined under “Creating the Fields” and referenced under “Creating the Article Template File”; there is just one image field, “article_images”. However, under section “Creating a Template”, that field (that has been setup to hold two images) has become the two fields “article_mainimage” and “article_secondimage” .  You could go both ways I guess; I used the method with one field (that best corresponds to the tutorial text) and that works as described. 
  • Additionally (but less of a problem), the field “article_meta_keywords” appear in the image under the “Creating a Template” section (without having been defined or referenced before) instead of the actually defined field, “article_metadescription”. The keywords-part is also unnecessarily in the TUT_header.inc under the early “Header and Footer” section. As it is not used, it should probably be removed.  

Other than that, I ran through the whole thing and everything works!

The one caveat is that I (for understanding and training) rewrote the php code references in the HTML myself using full php -syntax, so I can't vouch for there being no errors in the example code in that regard, but I followed along with the examples so I doubt it. 

All in all, not a bad way to take the first tentative steps into the world of php and cms in general - and ProcessWire in particular - for someone who is new to all this (like I am). Thanks again for your help! /ND

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

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