Search code examples
tagspyrocms

Pyrocms tag as parameter in another tag


I tried to use {{ page:slug }} as a parameter in my page to get the blog articles from the category of the same name. For example:

  • Pagename = About me
  • Slug = about-me

Then create a category with the same name and slugname in Blog with associated articles. Now in pagelayouts I thought I could create the following, but it doesn't seem to work. Does anyone know why not?

{{ blog:posts order-by="created_on" dir="asc" category="{{ page:slug }}" }}
<section class="title">
    <h4>
    {{ title }}
    </h4>
</section>
<section class="item">
    <p>{{ intro }}</p>
    <p><a href="{{ url }}">Read more..</a></p>
</section>
{{ /blog:posts }}

Solved

I found the answer by asking it face to face to another developer. Since this is a templating language, it doesn't support functionality. It just reads pre-made variables. So I will have to solve this problem by creating another method in pages/plugins.php.


Solution

  • You don't need to try and embed a tag in a string, just pass the tag straight to the attribute.

    {{ blog:posts order-by="created_on" dir="asc" category="{{ page:slug }}" }}
    

    Should be:

    {{ blog:posts order-by="created_on" dir="asc" category=page:slug }}
    

    Easier than you thought ey?