Changing projects url breaks projects snippet


I’m diving into Kirby to see if I can use it for a client project. I installed the starter kit (2.3.2). The backend looks really awesome and I love the massive amount of documentation.

I played around in the backend panel and noticed that if the URL appendix is changed for the Projects page, the projects.php snippet no longer works due to the uid/id/slug change. The cache folder is empty by the way.

Is there a way for a panel user (i.e. client) to change a page url and after that the related snippet without having to access the site via FTP? Or even better (since my clients are not really into php and html): is there maybe a way that I can trigger for the projects.php snippet to be updated with the new identifyer after a user changes the URL appendix?


You can use a variable in the snippet:

<?php foreach($projects->children()->visible()->limit(3) as $project): ?>

And when you call the snippet in the projects.php template, pass the the variable to the snippet:

<?php snippet('projects', array('projects' => $page)) ?>

If you do it this way, the uid of the page is irrelevant. But you will have a problem when the snippet is called in the home.php template. Then you would need another method to find the correct page, e.g. by template.

1 Like

Hi texnixe,
thanks for that :sunny: - it works (the template code needs an extra ‘)’ to close the snippet call) .

Thanks for the tip on finding the correct page by template (might be something I need to look into for a onepager).

Have a great day!

Yeah, sorry, I always forget my parenthesis when not in my editor …:worried:

As for finding the page by template:

$projectsPage = $pages->findBy('intendedTemplate', 'projects');
1 Like

No problem at all :slight_smile: and thank you very much for the pro-active ‘finding page by template’ help :relaxed:

You are welcome :slight_smile: We are here to help …