0

我正在使用 OctoberCMS DynamicPDF插件,它按照我的要求工作得非常好。

Howerver,我有动态 PDF 标题文本内容,我正在尝试覆盖我的标题内容,但它不起作用。这是我到目前为止所尝试的。

模板文件

{% set headerTExt = 'asdf' %}

布局文件

 <html>
        <head>
            <style type="text/css" media="screen">
                {{ css|raw }}
            </style>
            <title>Regency Brochure</title>
        </head>

        <div id="header">
             <div style="display: inline-block; position: absolute; left: 2.5%; top: 12px;">
                <img src="{{  logo }}" style="width: 60px; height:auto; margin-top:5px;"/> 
             </div>
             <div style="text-align: right; font-size: 20px; color: #b49132; text-transform: uppercase; font-family: 'Montserrat-Bold'; position: absolute; right: 3.5%; top: 25px;">
{{ headerTExt }}
</div>
          </div>
          <div id="footer">
             <div class="footerText">www.regencycorporate.com.au</div>
          </div>




            {{ content_html|raw }}

    </html>

布局文件 CSS

@page { margin:25mm 0px 8mm 0px;}
         header { position: fixed; left: 0px; top:-25mm; right: 0px; height: 22mm;   background-color: #fff;   border-bottom: solid 1px #d8d8d8;}
         footer { position: fixed; left: 0px; bottom:-8mm; right: 0px;    background-color: #b49132; height: 11mm; }
         footer .footerText { font-size: 14px; text-align: center; color: white;    font-family: 'Montserrat-Medium'; font-weight:400; padding-top:8px; }
         content{
         height:645px;
         padding:0px 30px;
         }

如您所见,我正在尝试通过将动态标题文本{{ headerTExt }}设置在带有变量的模板文件中,{% set headerTExt = 'asdf' %}但它不起作用。如果我放置静态文本,它的工作但动态不工作。

有人可以指导我如何使它工作

4

1 回答 1

3

您正在寻找{% placeholder %}https ://octobercms.com/docs/markup/tag-placeholder

模板文件:

{% put headerText %}Test{% endput %}

布局文件:

<html>
    <head>
        // etc
    </head>
    <body>
        <div id="header">
            {% placeholder 'headerText' %}
        </div>
    </body>
</html>
于 2019-04-16T13:08:03.310 回答