Code Question - Combined Audio

Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
In the Combined Audio index.tpl, how do I require that the displayed result have a picture.

I can't just say require_image="audio_image" because the Soundclouds would disappear.

So I believe I would need to add some kind of if/then statement that targets only uploaded songs and requires them to have a picture.

That would somehow have to be added to the module call but I don't know how to integrate it.

 {jrCombinedAudio_get_active_modules assign="mods"}
        {if strlen($mods) > 0}
            {jrSeamless_list modules=$mods order_by="_created random" pagebreak=10 page=$_post.p pager=true}
        {elseif jrUser_is_admin()}
            No active audio modules found!
        {/if}   



--

Ken Rich
indiegospel.net

updated by @ken-rich: 08/09/15 04:45:05PM
michael
@michael
9 years ago
7,718 posts
Nice question, good to see you getting into the code. Did you give it a try? That looks like it might work,

{jrSeamless_list modules=$mods order_by="_created random" pagebreak=10 page=$_post.p pager=true require_image="audio_image"}
{jrSeamless_list modules=$mods order_by="_created random" pagebreak=10 page=$_post.p pager=true require_image="*_image"}

I'd try those two first and if they didn't provide the results you were after then think about looking at the item_list.tpl files for the individual items. You could put an {if} in the audio one to check that there is an image and not show it if there isn't.
Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
Hi Michael,

Your first suggestion removes all the Soundclouds, along with the uploaded songs that are missing images.

Your second suggestions removes all songs.

I'm not sure what you mean with the item_list.tpl suggestion.

I was thinking of an if statement something like
{if $mod="jraudio" require_image=audio_image}
being integrated with the existing code.

I don't know how to do it though, since there is already an if and an elseif, and another if "layer" is too complex for me.


--

Ken Rich
indiegospel.net
michael
@michael
9 years ago
7,718 posts
What you were thinking is good thinking, its just that it won't work in this location because you only want 1 seamless call, not two.

So the next place to look is the list template. You dont have template= in there at all, so Seamless is using the default list template which is:

/modules/jrSeamless/templates/item_list.tpl

It looks like this:
{if isset($_items)}
{foreach $_items as $item}
    {if is_file("`$jamroom_dir`/modules/`$item.seamless_module_name`/templates/item_list.tpl")}
        {jrSeamless_parse_template item=$item template="item_list.tpl" module=$item.seamless_module_name}
    {elseif jrUser_is_admin()}
        item_list.tpl for {$item.seamless_module_name} not found<br>
    {/if}
{/foreach}
{/if}

That reads: For every item that has been found, check to see if the module has an item_list.tpl file, if it does show that file.

So you want to change what it reads to make sure that it has an image if its an audio file, so you want it to read:
For every item that has been found, if the item is a jrAudio item make sure it has an image and check to see if the module has an item_list.tpl file and that the module is not , if it does show that file.

So try:
{if isset($_items)}
{foreach $_items as $item}
    {if $item.seamless_module_name == 'jrAudio' && !isset($item.audio_image_size)}
      {continue}
    {/if}

    {if is_file("`$jamroom_dir`/modules/`$item.seamless_module_name`/templates/item_list.tpl")}
        {jrSeamless_parse_template item=$item template="item_list.tpl" module=$item.seamless_module_name}
    {elseif jrUser_is_admin()}
        item_list.tpl for {$item.seamless_module_name} not found<br>
    {/if}
{/foreach}
{/if}