Sauter la navigation

[Résolu] Hyperlinking repeatable fields in a carousel

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Hyperlinking repeatable fields in a carousel

Solution:
You can display the repeating fields using [wpv-for-each] shortcode and display the carousel.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/hyperlinking-repeatable-fields-in-a-carousel/#post-908787

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each
=> https://toolset.com/2017/10/adding-a-gallery-of-images-for-custom-posts/

This support ticket is created Il y a 6 années et 7 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Marqué : ,

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par PiotrO586 Il y a 6 années et 7 mois.

Assisté par: Minesh.

Auteur
Publications
#908585

Hi,

I set up a carousel from images included in a repeatable field:

	<div class="carousel-inner">
		<div class="item active">
			[types field="images" size="thumbnail" align="none" separator="</div><div class='item'>"][/types]
		</div>
	</div>

I was wondering how could I link each image to show it in a lightbox?

I use the following code for linking individual images:

<a href="[types field='images' size='full' url='true'][/types]" data-featherlight>[types field="images" size="thumbnail" align="none" separator=", "][/types]</a>

but I am not sure if and how can I use it with above carousel?

#908787

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - as I understand your image field is multiple instance (repeating) field - correct? If yes:
=> Have you checked view's shortcode [wpv-for-each]

For example:

<div class="carousel-inner">
[wpv-for-each field="wpcf-images"]
<div class="item">
        <a href="[types field='images' size='full' url='true'][/types]" data-featherlight>[types field="images" size="thumbnail" align="none"][/types]</a>
  </div>

[/wpv-for-each]
</div>

More info:
=> https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-for-each

Additionally, following article may help you:
https://toolset.com/2017/10/adding-a-gallery-of-images-for-custom-posts/

#908849

Hi Minesh,

yes, I know this approach. But as my example shows, I need to distinguish between first item, and the rest of them. The first item has classes "item" and "active", while subsequent have only "item".

Your suggestion doesn't allow to check whether the item is first in a loop.

I was trying to use shortcode to generate index (like here: https://toolset.com/forums/topic/incremental-row-numbers-in-views/#post-31061), but it doesn't work either.

#908854

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Well - if you only have issue to add an active class name to first item - we can manage it by adding little custom jQuery code:

For exaple:

jQuery(document).ready(function($){
$('.carousel-inner div.item:first').addClass('active');
});

If above solution does not work - then I need to check on your install why the solution that you shared to increment the index is not working. For that I need problem URL and access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#909130

Thanks Minesh,

it worked.