<?= css('@auto') ?> works wrong!?

Dear Ladys or Gentleman,

i’ve make a css adjustment for another site. This site doesn’t need a separate template but if i doesn’t copy the default template and name it to the sitename the helper doesn’t load the modified css. Is that a bug or a feature i don’t understand?

Best regards
Chris

You would need to call the stylesheet default.css. (although i have never done this with just the default template being used) The style sheets must match the name of the template they belong to.

I would suggest just loading the css file directly. If you only have one template file, using auto doesnt make much sense.

I have one stylesheet and sometimes want to make adjustments in another additional css per <?= css(‘@auto’) ?>. That makes fully sense to keep the code small and clean. But it will actual only work if there is a separate (maby an exact copy of parent) template wich is named like the css. Otherwise <?= css(‘@auto’) ?> would be ignored.

It seems the <?= css(‘@auto’) ?> is a child of the template but is think it would be smart it works like the logic of searching for different templates.

Hm, I don’t really understand what you are trying to say or what exactly the problem is. What exactly does not work?

CSS autoloading works exactly as described in the docs: css() | Kirby CMS

I think it would be a benefit to separate the logic of searching for additional css from the template. At this moment i need a css wich is called similar to the template and a template called similar to the page. But the template must exist. In my opinion that is not neccessary because in my case i have to copy the default template to make a additional css correctly included.

My workaround is to generate a template called similar to the page but the code within just include the default template.

I still don’t get what sort of linking between template and stylesheet you would expect. How is the template supposed to know what CSS stylesheet to include or not, if not based on filename? Of course, you could have a field in each page that defines which stylesheet to load, then you can include logic that does exactly that.

A special stylesheet doesn’t need a direct linked special-template in my opinion! That is my point of view with my actual knowlege about. And it is to discuss. Why couldn’t it be loaded same way as kirby look for special templates.

Content:
Page_1
Page_2
Page_3

Template:
defalut.php

Asstets, CSS:
default.css (direct link)
Page_3.css (additional to default, loaded per @auto, named as same as content)

And if you change the page slug, you would also have to rename the stylesheet. Wouldn’t be too great if the page layout stops working as intended because the user changed the page slug.

Kirby’s @auto works based on template, not based on filename. If you need it to work by page slug, you can create your own css helper?

If the user changed page slug he need to change the name of template too. It’s not that big argument or i’m definitly thinking in wrong directions. - I will have to think about your trigger about css helper,…

No, why? Different pages with different page slugs often use the same template, for example, the articles in a blog. So if you change the page slug, you don’t change the template.

So, adding the CSS on a per-template basis makes absolute sense, you wouldn’t want to have different CSS per page in this case.

In any case, this is how @auto works and IMO it makes sense like that.

Apart from that, as already mentioned above, you can extend Kirby in almost any way you can think of and create your own helpers in a plugin. You are by no means limited to the Kirby core.

For page specific stylesheets, this quicktip might be of interest: Art-directed pages | Kirby CMS

For user-generated CSS you would probably add a field and then include via style tag in your template head.

So, to summarize: The @auto feature works exactly as intended, even if different from your expectations.

Thanks for the impulses.