Using {capture} Instead of a List Template File

Applies to: Jamroom 7.0+ Last verified: 2026-10-24
  • Why

    {jrCore_list} formats its items with a template file. When you can't add a file, such as in the Template Editor or a Site Builder Template Code widget, put the template code in a variable with Smarty's {capture}, and pass that.

  • How

    {capture assign="audio_template"}
    {literal}
        {foreach $_items as $item}
            <a href="{$jamroom_url}/{$item.profile_url}">{$item.audio_title}</a><br>
        {/foreach}
    {/literal}
    {/capture}
    
    {jrCore_list module="jrAudio" order_by="_created numerical_desc" limit="10" template=$audio_template}
    • {capture} puts its content in $audio_template instead of showing it.
    • {literal} keeps the inner tags as text, so they're run by {jrCore_list} for each list, not when the capture is made.
    • template=$audio_template passes code instead of a file name.
  • Using values from the URL

    Values in the address are in $_post. On a page at yoursite.com/songs/5, {$_post.option} is 5:

    {jrCore_list module="jrAudio" profile_id=$_post.option template=$audio_template}
  • File or capture?

    Use a file when the same template is used in several places. Use {capture} for a one-off list, or where you can't add files.

Tags