Problem with snippet($section->uid())

Hi all,

I’ve built a site using Kirby 2 and have encountered a problem when transferring to a remote server.

I’m using the ‘one-pager’ technique as documented here, to get a snippet called projects.php showing on the home page:

On my local server (using MAMP) everything displays fine - on the remote server, the projects.php snippet is missing from the home page and I cannot for the life of me work out how to get it to show. The server is running PHP 5.4.40. I am using the following code to pull in the sections:

foreach($pages->visible() as $section) {
snippet($section->uid(), array(‘data’ => $section));

At first I thought it might be an issue with file permissions (assuming the page was trying to pull something in that it couldn’t access) and have set all file permissions to 755. Still no luck. any ideas would be greatly appreciated!


Hm, there are several reasons why that could fail. The most basic ones:

  • Have you verified that the naming of the page (projects) and the template is consistent?
  • Have you verified that every file has been uploaded (especially the snippet)?

Also: Is only the projects snippet missing or are others affected as well?

You could try echoing $section->uid() in your loop (before calling snippet()). If the string project appears, it’s an issue with your snippet, otherwise with the page.

Hey lukasbestle, thanks for your help. Tried echoing certain things and managed to trace it to the core problem.

Turns out it didn’t like the $data variable that I had set on the homepage. I noticed in the Kirby 2 demo site that the loop avoids using a variable (as recommended in the tutorial) and was written as:


rather than:


Tried the former and it worked. I’d love to know why using the $data technique worked fine on the local site but not on remote (as the files were copied like for like). anyone got an idea? If not, no worries as the problem is solved!

Many thanks for your help

Hm, that’s quite strange…
Glad that you have found a solution.