CAS 6.0.3 ignores header and footer in my theme

81 views
Skip to first unread message

Maksim Kopeyka

unread,
Nov 11, 2019, 1:29:43 PM11/11/19
to CAS Community
Hi Guys,

I have to create a custom theme. According to documentation this task is simple enough. However CAS ignores 2 of 3 fragments of my theme. I see my login form but header and footer is ignored and CAS shows default header and footer.

This is my folders structure:
  • resources/templates/test
    • fragments
      • footer.html
      • header.html
      • loginform.html
    • casLoginView.html
    • layout.html
The content of all files is trivial. I expected to see a white screen with HEADER, FOOTER and LOGIN FORM text however I see a big CAS logo with default header and footer and with text LOGIN FORM. How to override header and footer fragments?

casLoginView.html
<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
<head>
   
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
   
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
   
<title th:text="#{cas.login.pagetitle}">CAS Acceptable Use Policy View</title>
</head>
<body class="login">
<main role="main" class="container mt-3 mb-3">
   
<div layout:fragment="content" class="row">
       
<div class="col-md" th:if="${delegatedAuthenticationProviderDominant == null}">
           
<div th:replace="test/fragments/loginform :: loginform">
               
<a href="test/fragments/loginform.html">Login Form goes here</a>
           
</div>
       
</div>
   
</div>
</main>
</body>
</html>

layout.html
<!DOCTYPE html>
<head>
    <meta charset="UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title layout:title-pattern="$CONTENT_TITLE - $LAYOUT_TITLE">CAS &#8211; Central Authentication Service</title>
</head>
<body>
<div th:replace="test/fragments/header :: header">
    <a href="test/fragments/header.html">Header</a> fragment will go here
</div>
<main role="main" class="container mt-3 mb-3">
    <div layout:fragment="content" id="content">
        CAS content will go here
    </div>
</main>
<div th:replace="test/fragments/footer :: footer">
    <a href="test/fragments/footer.html">Footer</a> fragment will go here
</div>
<script th:replace="test/fragments/scripts"/>
</body>
</html>

footer.html - ignored
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title>Footer Fragment</title>
</head>
<body>
    <footer th:fragment="footer" class="footer" role="contentinfo">
    <div>FOOTER</div>
    </footer>
</body>
</html>

header.html - ignored
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title>Header Fragment</title>
</head>
<body>
    <header th:fragment="header" role="banner">
        <div>HEADER</div>
    </header>
</body>
</html>

loginform.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title>Login Form Fragment</title>
</head>
<body>
<main role="main" class="container mt-3 mb-3">
    <div class="row">
        <div class="col-md">
            <div th:fragment="loginform" class="form_container">
                  LOGIN FORM
            </div>
        </div>
    </div>
</main>
</body>
</html>


Maksim Kopeyka

unread,
Nov 11, 2019, 6:17:30 PM11/11/19
to CAS Community
My bad, I didn't set theme prefix for this line in casLoginView.html:
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">

 So with prefix everything works as expected:
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{test/layout}">

Steve Cheung

unread,
Nov 11, 2019, 9:56:29 PM11/11/19
to cas-...@apereo.org
Hi Maksim,

I want to do the same thing here to custom a  login form. May I know which url you follow to do? 

Thanks, Steve

--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/956f5905-17cc-42b0-a642-0723b9d20c16%40apereo.org.

Maksim Kopeyka

unread,
Nov 12, 2019, 1:32:28 AM11/12/19
to CAS Community
Reply all
Reply to author
Forward
0 new messages