Avatar
0
tvd12 Enlightened
tvd12 Enlightened
Khai báo biến slug và sử dụng biến slug này để gọi hàm lấy tiêu đề trang trong thymeleaf
Tôi đã có:
slug=${ezyfunctions.call('get_request_parameter', '{name:\'slug\'}')}

Làm thế nào để sử dụng nó trong hàm ezyfunctions.call('get_post_title_by_slug' để lấy tiêu đề trang?

  • Answer
thymeleaf
Remain: 5
1 Answer
Avatar
tvd12 Enlightened
tvd12 Enlightened
Bạn có thể sử dụng thẻ th:block với thuộc tính th:with như sau:
<th:block th:with="slug=${ezyfunctions.call('get_request_parameter', '{name:\'slug\'}')}, pageTitle=${ezyfunctions.call('get_post_title_by_slug', '{slug:\'' + slug + '\'}')}">
    <title>[[${pageTitle}]]</title>
    <meta name="title" th:content="${pageTitle}" />
    <meta property="og:title" th:content="${pageTitle}" />
    <meta property="og:site_name" th:content="${pageTitle}" />
</th:block>
  • 0
  • Reply