Git Product home page Git Product logo

layouts's People

Contributors

afbora avatar bastianallgeier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

8grad modufolio

layouts's Issues

Minimum required PHP version

I think the PHP requirement in the composer.json might be wrong.
Right now I can't install this plugin on PHP 8.2.3 as it has to be below 8.2.0.
Using >=8.0.0 <8.3.0 should probably fix that.

Breaks `$page->render()`

I've been preparing an error issue for the Kirby Static Site Generator not working if layouts are used, but looking closely at the problem, it seems there's something weird happening with the render() function when the layouts plugin is used.

If I call $page('error')->render() with the layouts plugin on, the $page refers to the error (correct) page in the layout, but refers to the last rendered / first requested page (see edit) in the template itself.

You can see the problem in the kirby/ssg/layouts demo repo build files:

result of page('error')->render():

<!DOCTYPE html>
<html class="no-js">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width">

	<title>Error • Site Title</title>
	<script type="module">
		document.documentElement.classList.remove('no-js');
		document.documentElement.classList.add('js');
	</script>

	<link rel="icon" href="/favicon.png">
	<link rel="icon" href="/favicon.svg" type="image/svg+xml">
</head>

<body class="antialiased dark:bg-gray-900 dark:text-white">

<h1>Home</h1>

</body>
</html>

Edit:

Order matters. templates get whatever page called 'render' first.

// generates `<h1>Error</h1>` in the template body
page('error')->render();

// generates `<h1>Home</h1>` in the template body of both
page('home')->render(); page('error')->render();

// generates `<h1>Error</h1>` in the template body of both
page('error')->render(); page('home')->render();

Nesting `slot()`s

Hey there,
I would like to nest slots - take the following scenario:

<?php slot('content') ?>
<section class="container">
    <?php slot() ?>
    some default content
    <?php endslot() ?>
</section>
<?php endslot() ?>

Most of the time, my templates would use slot(), drop some content, maybe echo $page->myfield()->toBlocks() etc but some templates would need to remove the container element and do something completely different. IMHO nesting slots would make this way more DRY, wouldn't it?

Thanks for considering this and have a good day,
S1SYPHOS

Global layout data not working

I tried to pass some data to the layout method, but I get "Undefined variable" error every time.

My template:
/site/templates/default.php

<?php layout("default", ["title" => "Some title"]) ?>

<p>Some content...</p>

Layout:
/site/layouts/default.php

<?= $title ?>

<?php slot() ?>
<?php endslot() ?>

Latest version of Kirby Plainkit, no other plugins installed.

Layout extending Layout

Hello there,
would it be possible for a layout to extend a layout? Eg layout blog calls layouts/default.php via layout()?

Thanks!

Cannot install on PHP 8.2 with composer

Hi there,

This issue was reported in #9 and marked as fixed, but the fix was never published to Packagist, so in practice it's still not possible to composer require getkirby/layouts with PHP 8.2.

Breaks pages cache

If i use layouts and slots the pages cache is no longer created.

If i return a string here instead of Tpl::load it works and cache files are created.
Layout Class

static public function render(array $data = []): string
    {
        Slots::render();
        return Tpl::load(kirby()->root('site') . '/layouts/' . static::$name . '.php', array_merge(Layout::$data ?? [], $data));
    }
'cache' => [
    'pages' => [
      'active' => true
    ]
  ]

$page->isCacheable() returns true.
kirby()->cache('pages')->set('a.html', 'test'); creates a file so not a permission error.

osx valet, kirby 3.6.6

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.