This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

moshem17556
moshem17556

I want to use the same layout for different pages, but add a unique class name for each of them. For instance, the home page may be <html class="home"> whereas the blog page may be <html class="blog"> and so on.

Any recommendations on how to do this?

Thanks

Last updated

Eoler
Eoler

moshem17556 said: Any recommendations on how to do this?

Docs: https://octobercms.com/docs/markup/this-page


<body class="{{ this.page.id }}">
moshem17556
moshem17556

Thanks.

In case anyone else needs to do something similar, I am using a combination of Eoler's answer plus a placeholder so that I can automatically add the page's id as a class as well as set unique classes when/if I want to.

Here is what the code on the layout page looks like:

<html class="no-js {% placeholder class %} {{ this.page.id }}" lang="">

And here is my code on the account.htm

{% put class %}inner{% endput %}

And here is what the output looks like:

<html class="no-js inner account" lang="">

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.