Template customization -> jrGallery -> can't find (datastore key)'s to make correct call

Xephius
Xephius
@xephius
7 years ago
93 posts
Hey all, I am modifying a template. It is designed to show the profile image of a user, but I don't want that. Instead, I would like it to make it display the latest image uploaded to a users Galleries. I have read the docs, but am clearly missing something. ;)

Here is the original code
{if isset($_items)}
    {foreach from=$_items item="item"}
        <div class="col3">
           <div class="wrap">
               <a href="{$jamroom_url}/{$item.profile_url}">
                   {jrCore_module_function
                   function="jrImage_display"
                   module="jrProfile"
                   type="profile_image"
                   item_id=$item._profile_id
                   size="xlarge"
                   crop="auto"
                   class="img_scale"
                   alt=$item.profile_name
                   title=$item.profile_name
                   }
               </a>
           </div>
        </div>
    {/foreach}
{else}
    {jrCore_include template="no_items.tpl"}
{/if}

And here is my modified code. I attempted to remove the tags that link back to the users account and displays the name. I also tried to change the source it was pulling the images from, but I now I get an error saying I don't have the proper "type" defined. I looked up the docs and found:

(jamroom url)/(module url)/image/(datastore key)/(item_id)/(size)

But that didn't give me a list of what key's those could be, or where to find where that working list maybe on my site. Again, sorry I am not understanding. My code:

{if isset($_items)}
    {foreach from=$_items item="item"}
        <div class="col3">
           <div class="wrap">
                   {jrCore_module_function
                   function="jrImage_display"
                   module="jrGallery"
                   item_id=$item._item_id
                   size="xlarge"
                   crop="auto"
                   class="img_scale"
                   }
           </div>
        </div>
    {/foreach}
{else}
    {jrCore_include template="no_items.tpl"}
{/if}

updated by @xephius: 06/19/17 09:18:00AM
brian
@brian
7 years ago
10,148 posts
The problem here is you are not telling the system WHAT image you want to show. When displaying a profile (or user) image it is easy, since all accounts only have ONE of them. But you could have a THOUSAND gallery images, so the part missing here is you need to get the _item_id of the LATEST image uploaded, which is going to require a jrCore_list call to get that info, as well as as small custom template to just return the ID.

Is this going to be loaded on every page? If so I would recommend a custom module or smarty function instead of doing it with a jrCore_list call.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
michael
@michael
7 years ago
7,714 posts
Try with type="gallery_image"

{if isset($_items)}
    {foreach from=$_items item="item"}
        <div class="col3">
           <div class="wrap">
                   {jrCore_module_function
                   function="jrImage_display"
                   module="jrGallery"
                   item_id=$item._item_id
                   type="gallery_image"
                   size="xlarge"
                   crop="auto"
                   class="img_scale"
                   }
           </div>
        </div>
    {/foreach}
{else}
    {jrCore_include template="no_items.tpl"}
{/if}


That is with the proviso that you still need to be inside a jrCore_list call like brian said so that you have images in the first place.

Docs: "{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1477/debug

if you add {debug} to that location you will see what variables you have to work with.
Xephius
Xephius
@xephius
7 years ago
93 posts
Cool. I think I understand both of you guys. :) Thanks.