Jump to content
ridgedale

PW3 - Children Rendering Incorrectly

Recommended Posts

Hi,

I've separated the header and footer information from the _main.php (_header.php and _footer.php). This works fine with any top level page but any page children are rendered without the header and footer information. When I add includes to the blog-post.php, for example, and try refreshing the page the following error is returned:

Quote

Fatal error: Call to undefined function ukBlogPost() in /<path to site folder>/site/assets/cache/FileCompiler/site/templates/blog-post.php on line 8

Error: Call to undefined function ukBlogPost() (line 8 of /Users/dene/Desktop/WebSrv/devDLF2/site/templates/blog-post.php)

The line of code being referred to is:

	echo ukBlogPost(page());

Could this error be being generated because I am working locally using MAMP?

Any assistance would be greatly appreciated.

Share this post


Link to post
Share on other sites

Hi @ridgedale

It looks like namespace issue. Try to add

namespace Processwire; 

to the top of your blog-post.php file

  • Like 1

Share this post


Link to post
Share on other sites

Hi Zeka,

Thank you for your reply. That appears to be getting somewhere as some of the child pages are now displaying OK.

However, the blog-post pages and now the contact page are generating the following same error:

Quote

Notice: Undefined variable: home in /<path to site folder>/site/templates/_header.php on line 60

Fatal error: Call to a member function and() on null in /<path to site folder>/site/templates/_header.php on line 60

Error: Call to a member function and() on null (line 60 of /<path to site folder>/site/templates/_header.php)

The line of code referred to is as follows:

<?=ukNavbarNav($home->and($home->children), [ 

That code has not been modified from the site-regular profile. It's a bit odd as all the pages load that code and it now appears that just the blog-post and contact pages throw up that error message.

Update:

Adding the following line after namespace Processwire; code

$home = pages()->get('/'); // homepage

gets rid of the error message but the blog-post pages are still not rendering properly. The pages now appear to be rendering twice and all the margins are messed up.

Any advice would be appreciated.

Share this post


Link to post
Share on other sites

Update:

The blog-post.php page rendering issue was resolved by removing the _header.php and _footer.php includes. ???

Thanks again to Zeka for his initial assistance.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      Despite my searches of the forum I'm somewhat confused about how to create new child pages on the frontend when a user clicks on a button on the parent page. I also have an equivalent button that is intended for uploading a .csv file to automatically create multiple new pages. This basically relates to a club (parent) and members (child) template configuration. Hopefully this explanation makes sense.
      A button should be able to launch the code needed to initiate the script required to create a new page using something like:
      <a href="/path/page.php">New +</a> <a href="/path/page.php">New ++</a> Does the code to create the new page or new pages need to be run from the template file for the child or the parent?
      A new individual member page will need to be editable manually at the point of page creation as well as subsequently, whereas multiple new pages will need to be editable after they have created and populated with data, again, as well as subsequently.
      I would very grateful for any advice or pointers as to how to achieve this.
       
    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      I was wondering if there is a way to restrict user navigation to specific pages.
      Login (home.php - not to be displayed)
          |__  About (not to be displayed)
          |__  Clubs (not to be displayed)
          |            |__ Club (to be displayed)
          |                       |__  Club Members (to be displayed)
          |__ League (not to be displayed)
          |            |__Season (not to be displayed)
          |                       |__  Match (not to be displayed)
          |__  News (blog.php -  to be displayed)
          |
      etc, etc
      Based on the above the navigation needs to appear simply as:
      ---------------------------------------------------------------------------
                           Club    Club Members    News    
      ---------------------------------------------------------------------------
      Any thoughts appreciated.
    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      I am trying to create a process whereby when a user logs in to their profile page (the user is automatically redirected to their profile page on login) and they then go to their 'members' page and creates a child page ('club-member'), the data stored in the user template ($user->usercode) is automatically added to the equivalent field on the club-member page.  This will be applicable only to the template used for the 'club-member' pages. Once the new page has been created the equivalent 'usercode' field on the 'club-member' page should not be subsequently editable.
      Below is the page hierarchy for visual reference:
      Login (home)
          |__  profile
                      |__  members
                                     |__  club-members
      It seems like an AddHookBefore might be the solution here such as:
      wire()->addHookBefore("Pages::saveReady", function($event) { $page = $event->arguments(0); if($page->template == 'club-member') { $clubcode = $user->club_code; $field = $page->club_code; $field->set('value', $clubcode); } }); I am I on the right track or is there a better way to achieve this?
      Any thoughts appreciated.
    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      I've setup a page where a member can edit contact details via the frontend displaying the field content using the <edit> ... </edit> tags.
      This works fine when the fields actually contain data. However fields that contain no data (i.e. empty) do not appear to be editable. No edit cursor appears (- possibly owing to the field width being 0px?)
      Is the only solution to recreate the page using a form, for example,  or is there a simple way to allow blank fields to be editable on the frontend?
      I wondered if anyone else has found a solution to this problem. Any assistance would be appreciated.
    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      I am trying to add a field that provides a dropdown menu but there are no Options or Selector(s) type available - see attached image of field types available.
      The following reference under the docs does not appear to be applicable any more:
      https://processwire.com/api/modules/select-options-fieldtype/
      I can't see how to achieve this. Any assistance would be appreciated.

×
×
  • Create New...