45 lines
1.7 KiB
Markdown
45 lines
1.7 KiB
Markdown
# Workspace Rules
|
|
|
|
### Creating New Thymeleaf Pages
|
|
When creating or scaffolding a new Thymeleaf template page in this project, you MUST use the `layout:decorate` mechanism to inherit the common layout, and you MUST pass the `bodyClass` variable to maintain consistent styling with the homepage.
|
|
|
|
Use the following exact structure as a template:
|
|
|
|
```html
|
|
<!DOCTYPE html>
|
|
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
layout:decorate="~{fragments/layout(bodyClass='umass-platform-homepage path-frontpage page-node-type-homepage homepage transparent-header')}">
|
|
|
|
<head>
|
|
<title>Tiêu đề trang</title>
|
|
</head>
|
|
|
|
<body>
|
|
<div layout:fragment="content">
|
|
<!-- Content Top Banner -->
|
|
<div class="content-top">
|
|
<!-- Banner content here -->
|
|
</div>
|
|
|
|
<!-- Main Content Area -->
|
|
<div class="main-content-area">
|
|
<!-- Specific page content here -->
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
```
|
|
|
|
### Dynamic Theme Component Inclusion
|
|
When writing or modifying Thymeleaf templates for the public frontend, NEVER hardcode paths for common layout components (such as header or footer) to a specific theme (e.g., `themes/umass/header`) or to the default fallback (e.g., `fragments/footer`) unless explicitly building an admin/manage page.
|
|
|
|
Instead, ALWAYS use the `activeTheme` variable to dynamically load the active theme's component.
|
|
|
|
**Correct Usage:**
|
|
`<header th:replace="~{themes/__${activeTheme}__/header :: header}"></header>`
|
|
`<footer th:replace="~{themes/__${activeTheme}__/footer :: footer}"></footer>`
|
|
|
|
**Incorrect Usage:**
|
|
`<div th:replace="~{themes/umass/header}"></div>`
|
|
`<footer th:replace="~{fragments/footer :: footer}"></footer>`
|