Search code examples
phpcodeigniterpyrocmspyro

pyrocms i want to display keywords separated in the loop


this code display applied keywords to the childrens pages

{{ pages:children id="1" order-dir="desc" limit="15"  }}
{{ custom_fields }}
{{keywords}}
{{ /custom_fields }}
{{ /pages:children }}

I have 3 keywords applid to some page so i want to display keywords separated in the loop and not as a string with all keywords in one loop but to be aloop with number of keywords related something like

{{ pages:children id="1" order-dir="desc" limit="15"  }}
{{ custom_fields }}
{{loop}}
{{keywords}}
{{/loop}}
{{ /custom_fields }}
{{ /pages:children }}

Please help


Solution

  • You can display keywords separately as well - just use opening and closing tags;

    {{ if keywords }}
        <div class="keywords">
            {{ keywords }}
              <span><a href="{{ url:site }}blog/tagged/{{ keyword }}">{{ keyword }}</a></span>
            {{ /keywords }}
        </div>
    {{ endif }}
    

    The above is taken from the Blog module single post view - look in /system/cms/modules/blog/views/view.php for the source. The Keyword field type docs also have a couple of similar examples.