Skip Navigation

[Resolved] output a file name linked with a url field in a View content template -repeating

This thread is resolved. Here is a description of the problem and solution.

Problem:

how to show the repeating titles properly linked by their repeating URL fields.

Solution:

Types repeatable field groups are based on one-to-many relationship, so each item is also a single post.

You try these:

https://toolset.com/forums/topic/output-a-file-name-linked-with-a-url-field-in-a-view-content-template-repeating/#post-1247583

Relevant Documentation:

This support ticket is created 4 years, 11 months ago. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by martinE-4 4 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#1247425

Tell us what you are trying to do?
I have two repeating custom fields: field_resource_link_url and field_resource_link_title

I want to design a content template like:

Resource(s):
Resource file Title 1(linked to its URL)
Resource file Title 2(linked to its URL)
etc.

I can output either title or the other custom field url in a VIEW, but I can't seem to figure out how to show the repeating titles properly linked by their repeating url fields.

Using html, I was experimenting with <a href="[Any value ShortCode]" >[Any Label ShortCode]</a>
but couldn't get it to work when I put the types shortcode in as:
<a href="[types field='field_resource_link_url' separator='<br>'][/types]" >[types field='field_resource_link_title' separator='<br>'][/types]</a>

Thanks for the help,
Martin

#1247433
Edit Group ‹ ICASC MIgration 1 — WordPress.jpg

I forgot to mention that the reason I'm not using a 'FILE' field type is that this site is a migration of a large Drupal site using the FG Drupal to WordPress plugin and it created the two fields url and title which are populated with a lot of data...

(see image for field definition)

#1247583

Dear Martin,

I assume we are talking about a repeatable field groups "my-rfg", with two custom fields:
- field_resource_link_url
- field_resource_link_title
Types repeatable field groups are based on one-to-many relationship, so each item is also a single post.

You try these:
1) Create a post view:
- query the posts of your repeatable field groups "my-rfg"
- filter by:
Select items from the my-rfg group that are related to the Post where this View is shown.
- In section "Loop Editor", display the file title and links like this:

<a href='[types field='field_resource_link_url' output='raw'][/types]'>[types field='field_resource_link_title'][/types]</a>

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#url
‘raw’=Display raw data stored in DB. No other formatting attributes

#1255577

Sorry, I'm still having a problem.

I don't want to create a view with all the values of "my-rfg" for all the related posts. I just want the the values of "my-rfg" for my current post.

How do I just show the repeated values of "my-rfg" using the nice code which you showed here:

<a href='[types field='field_resource_link_url' output='raw'][/types]'>[types field='field_resource_link_title'][/types]</a>

BUT just for the current post (not the related ones too).

[note: I tried what you said above with the view editor Query Filter "Filter by post relationship or repeatable fields group owner" but my choices are then
"Select items (choose a relationship) as related items of...
and I choose "The post where this View is shown"
BUT
that is incorrect because it assumes I also want records related in some way to the current one. It doesn't allow me to just pick the current record repeated values]

thanks,
Martin

#1255741

I'm wondering if I have a group of repeating fields (URL and TITLE) rather than a repeatable field group. This database is created using the FG Drupal to WordPress plugin which while amazing may have missed this nuance.

Is it possible for me to change my field group of repeating fields into a repeatable field group or is there some other way around my problem of displaying the repeating field values in my "Resource" custom field type posts.

#1255743

Ok, I figured it out using repeating fields. No view just shortcode block:

<ul>
[wpv-for-each field="wpcf-field_resource_link_url"]
<li>
<a href='[types field='field_resource_link_url' output='raw' ][/types]'>[types field='field_resource_link_title'][/types]</a>
</li>
[/wpv-for-each]
</ul>

However, could you please tell me why it might be better to use repeatable field groups in the future? Thanks.

#1256477

For the question:
However, could you please tell me why it might be better to use repeatable field groups in the future?

repeatable field groups can contain multiple instances of multiple custom fields, but repeating field contains only one custom field in multiple instances.

For example you can setup repeatable field groups, like this:
- Item A. Title: Google, URL: google.com
- Item B, Title: Yahoo, URL: yahoo.com
...

See our document:
https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/

#1269677

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.