Photo Album List Display in Side Bar

PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
I am very close on this one, but I am stuck. The thumbnails of the photo albums are showing up with the correct link, but it is calling the wrong id for the image.

{if isset($_items)}
            {foreach from=$_items item="item"}
                <a href="{$jamroom_url}/{$item.profile_url}/{$murl}/{$item._item_id}/{$item.photoalbum_title_url}">{jrCore_module_function function="jrImage_display" module="jrGallery" type="gallery_image" item_id=$item._item_id size="small" crop="auto" class="img_shadow" width=58 height=58 style="padding:2px;margin-bottom:4px;" alt="{$item.photoalbum_title|jrCore_entity_string}" title="{$item.photoalbum_title|jrCore_entity_string}" _v=$item._updated}</a>
            {/foreach}
            {/if}

I know this is wrong: item_id=$item._item_id

but I have used the debug and replaced $item._item_id with everything I could see including $item.photoalbum_photos ...

Could someone throw me a bone on this one please?

Thanks :)


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

updated by @the-patria-company: 06/03/16 10:54:06AM
michael
@michael
8 years ago
7,715 posts
This is the code used in the photo albums item list file:
{jrCore_module_function function="jrImage_display" module="jrGallery" type="gallery_image" item_id=$img_id size="small" crop="auto"}

and its the same as yours, so all you need to do is figure out what the image id is that you're wanting to display is.

Look in the photo album's tempaltes for how it does it:
/modules/jrPhotoAlbum/templates/item_list.tpl
.....
{foreach $item.photoalbum_photos as $img_id}
                                    {if $i >= $limit}
                                        {continue}
                                    {/if}
                                    <a href="{$jamroom_url}/{$item.profile_url}/{$murl}/{$item._item_id}/{$item.photoalbum_title_url}">{jrCore_module_function function="jrImage_display" module="jrGallery" type="gallery_image" item_id=$img_id size="small" crop="auto" class="iloutline"}</a>
                                    {$i = $i+1}
{/foreach}
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
Agreed, and I did try that. I changed my {foreach} condition to $item.photoalbum_photos as $img_id and of course it messed up the hyperlink that is looking for $item. Can you have multiple conditions in the {foreach} statement?
{foreach from=$_items item="item" && $item.photoalbum_photos as $img_id}

I was looking around the code for possible examples of this, but I could not verify it. So I wanted to ask first.

Thanks so much for your help. :)


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
OK, I tried it and got a white screen :(

So I reverted to the original code at the top of the post.

I am really stuck, because it is pulling the correct photo album and making the correct link, but it is using the wrong image for the thumbnail.

Any other thoughts?


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
michael
@michael
8 years ago
7,715 posts
{foreach from=$_items item="item" && $item.photoalbum_photos as $img_id}
is not valid code
{foreach $_items as $item}
  {foreach $item.photoalbum_photos as $img_id}
// do something here....
  {/foreach}
{/foreach}

is valid code.
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
@michael, you are the coding BOSS!!!

Here is my new side bar photo album display (elastic skin), so far:

        {if !jrCore_is_mobile_device() && jrCore_module_is_active('jrPhotoAlbum')}

            {capture assign="my_photoalbums_tpl"}
            {literal}
            {jrCore_module_url module="jrPhotoAlbum" assign="murl"}
            {jrCore_module_url module="jrGallery" assign="gurl"}
            {if isset($_items)}
            {foreach from=$_items item="item"}
                {foreach $item.photoalbum_photos as $img_id}
                	<a href="{$jamroom_url}/{$item.profile_url}/{$murl}/{$item._item_id}/{$item.photoalbum_title_url}">{jrCore_module_function function="jrImage_display" module="jrGallery" type="gallery_image" item_id=$img_id size="small" crop="auto" class="img_shadow" width=58 height=58 style="padding:2px;margin-bottom:4px;" alt="{$item.photoalbum_title|jrCore_entity_string}" title="{$item.photoalbum_title|jrCore_entity_string}" _v=$item._updated}</a>
            	{/foreach}
            {/foreach}
            {/if}
            {/literal}
            {/capture}

            {jrCore_list module="jrPhotoAlbum" profile_id = "`$_profile_id`" assign="photoalbums" template=$my_photoalbums_tpl}
            {if strlen($photoalbums) > 0}
                <div class="block block_profile_left">
                    <h3>My Photo Albums:</h3>
                    <div class="block_content mt10">
                        <div style="padding-top:8px">
                            {$photoalbums}
                        </div>
                        <a href="{$jamroom_url}/{$profile_url}/photoalbum">More Photo Albums</a>
                    </div>
                </div>
            {/if}
        {/if}

This works for small sites, but will need some tweaking to organize larger photo albums, plus will need a condition added for a maximum number of images to show per album. If anyone wants to add some tweaks that would be great! :)


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
michael
@michael
8 years ago
7,715 posts
{foreach $_items as $item}
{$i = 0}
  {foreach $item.photoalbum_photos as $img_id}
    {if $i > 10}
      {continue}
    {/if}
    {$i = $i+1}
// do something here....
  {/foreach}
{/foreach}
That will limit it to 10 photos per album.

Tags