collectiveaccess / pawtucket2

Pawtucket Improved
GNU General Public License v3.0
82 stars 75 forks source link

Templates tags not showing in site page content in order #96

Closed Monica-Wood closed 7 months ago

Monica-Wood commented 7 months ago

Not sure if I should log this on the providence side or the pawtucket side...

If I have a template (.tmpl) in pawtucket, that has tags {{{ }}} inside a php if statement eg.

<?php           
    if($howtouse){ 
?>
        <h3>How to use this guide</h3>
        <div>{{{howtouse}}}</div>
<?php 
    } 
?>  

then those tags don't show in the site page content bundle in providence in the order they are used on the page. All tags inside php ifs are put to the bottom.

Bug, or by design?

dev/php8

collectiveaccess commented 7 months ago

Unless that php variable is set when the template is compiled the tag will never show. It's now templates work, not a bug.

Use tags to test ^howtouse rather than PHP.

Monica-Wood commented 7 months ago

I do have $howtouse = $this->getVar("howtouse"); at the top of the template. do you mean to using <ifdef> display templating in the .tmpl file instead of PHP?
I tried to find examples of display templating, in .tmpl file, but couldn't. Will have a play and try though.

collectiveaccess commented 7 months ago

Try something like this:

{{{<ifdef code="howtouse"><h3>How to use this guide</h3><div>^howtouse</div></ifdef>}}}

Monica-Wood commented 7 months ago

Unfortunately, It's not working. Setting the tags like this ends up with the site page editor looking like this: Screenshot 2024-02-14 at 1 31 32 pm

Guide.tmpl snippet

    <h1>{{{title}}}</h1>

    {{{<ifdef code="subtitle"><h2 id="subtitle">^subtitle</h2></ifdef>}}}
    {{{<ifdef code="scopecontent"><h3 id="scope">Scope and Content of Guide</h3><div class="lead">^scopecontent</div></ifdef>}}}
    {{{<ifdef code="howtouse"><h3 id="howtouse">How to use this guide</h3><div>^howtouse</div>}}}
    <div id="guide" class="bodytext">
        {{{bodytext}}}
    </div>  

From templates.conf

    title = {
        label = Page title,
        description = Title of page,
        width = 700px,
        height = 1,
    },
    bodytext = {
        label = content,
        description = Main content for page,
        usewysiwygeditor = 1,
        width = 700px,
        height = 300px,
    },
    subtitle = {
        label = Page sub title,
        description = Subtitle of page,
        width = 700px,
        height = 1,
    },
    scopecontent = {
        label = Scope and contents of guide,
        description = Shown above the main content of guide,
        usewysiwygeditor = 1,
        width = 700px,
        height = 100px,
    },
    howtouse = {
        label = How to use this guide,
        description = Shown above main content of guide and below scope,
        usewysiwygeditor = 1,
        width = 700px,
        height = 100px,
    },

And if I enter something into the field and hit save, the contents disappears, so it's not even as simple as it's using the value inside the {{{ }}} as the name.