Forum for discussing general topics related to Couch.
11 posts Page 1 of 2
Hi Guys

So what I'm doing is creating a gallery. I've created a gallery page and a gallery list page.

I am uploading multiple images per post which is correct, however on the list page I only want to display the first photo that was uploaded as the main thumbnail? How is this done?

Code: Select all
<cms:show_repeatable 'photos'>
       <img class="img-responsive" src="<cms:show portfolio_photo />" alt=""/>
       </cms:show_repeatable>


At the moment it is pulling all the uploaded images.
Please, modify it as
Code: Select all
<cms:show_repeatable 'photos'>
   <cms:if k_count = '1' >
       <img class="img-responsive" src="<cms:show portfolio_photo />" alt=""/>
   </cms:if >
</cms:show_repeatable>


If you place <cms:dump /> inside cms:show_repeatable block, you'd see k_count as one of available helping variables.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Thank you, works perfectly. One thing I forgot to ask - if you have a checkbox for each photo, how do you only display the photos that are checked?

Code: Select all
<cms:repeatable name='photos' label='Photos'>
       <cms:editable name="gallery" desc="Show in gallery" opt_values='Yes' type='checkbox'/>
       <cms:editable name='portfolio_photo' type='image' crop='1' width='150' height='150' input_width='100'/>
    </cms:repeatable>
Code: Select all
<cms:show_repeatable 'photos'>
   <cms:if k_count = '1' && gallery>
       <img class="img-responsive" src="<cms:show portfolio_photo />" alt=""/>
   </cms:if >
</cms:show_repeatable>

The code above outputs only first image AND if it is checked.

If picture is unchecked, then your variable gallery has no value; if checked, it has *some* value ('Yes' in your case). We can take advantage of that and proceed if value is set, without checking what exact value is there (link)

Please allow a suggestion:
<cms:editable name="gallery" desc="Show in gallery" opt_values='Yes' type='checkbox' col_width='50' />
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Fantastic :) Your suggestion is greatly appreciated and most welcome.

Learning new things everyday with CouchCMS.

Appreciate the help!
skud wrote: Fantastic :) Your suggestion is greatly appreciated and most welcome.

Learning new things everyday with CouchCMS.

Appreciate the help!

I am happy to be here because of the feedback like yours :D Thanks.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
If I may ask one more question regarding the checkbox code below. How would I show the latest 8 images the have been checked?

Code: Select all
<cms:show_repeatable 'photos'>
   <cms:if k_count = '1' && gallery>
       <img class="img-responsive" src="<cms:show portfolio_photo />" alt=""/>
   </cms:if >
</cms:show_repeatable>


This is my template:

Code: Select all
<cms:template title='Portfolio' clonable='1'>    
   
    <cms:repeatable name='photos' label='Photos'>
       <cms:editable name="gallery" desc="Show in gallery" opt_values='Yes' type='checkbox' col_width='50'/>
       <cms:editable name='portfolio_photo' type='image' input_width='100'/>
    </cms:repeatable>
   
    <cms:folder name='weddings' title='Weddings'/>
    <cms:folder name='street' title='Street'/>
</cms:template>
I see at least 3 definitions of 'the latest'. Could you elaborate?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Code: Select all
<cms:hide>1. SHOW ONLY CHECKED AND REMEMBER THEM IN REVERSED ORDER</cms:hide>
<cms:show_repeatable 'photos'>
<cms:capture into='reversed_order' >
   <cms:if gallery >
       <img class="img-responsive" src="<cms:show portfolio_photo />" alt=""/> |
       <cms:show reversed_order />
   </cms:if >
</cms:capture> 
</cms:show_repeatable>

<cms:hide>2. TAKE THE LIST SEPARATED WITH " | " AND SHOW ONLY 8 ELEMENTS</cms:hide> 
<cms:each var=reversed_order as='item' sep='|' >
<cms:if k_count le '8' >
    <cms:show item />
</cms:if>
</cms:each>


The code above will show 8 checked elements (or less) from the bottom of repeatable region (i.e. starting from last added row and going up, heading to first). Hope this is what you need :)

Have you checked the Gallery Core Concept? It is pretty powerful and things can be ordered by date, name, sorted asc/desc etc, because it is based on ordinary cloned pages. Uploading multiple photos at once also is a nice option.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Awesome, will definitely check the gallery core concept out. Thanks again! :D
11 posts Page 1 of 2