Skip Navigation

[Resolved] Change output repeating field

This support ticket is created 5 years, 5 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.

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/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 5 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1269131

Hi Toolset,

I have a repeating field and it outputs in plain text when i use: <?php echo types_render_field("responsibilities"); ?>

I would like to have it more like this:

<ul class="list-unstyled mb-7">
<li class="py-3">
<div class="media">
<span class="btn btn-xs btn-icon btn-soft-success rounded-circle mr-3">
<span class="fas fa-arrow-right btn-icon__inner"></span>
</span>
<div class="media-body text-secondary">
Work with our leadership team to drive strategic planning and prioritization
</div>
</div>

Is this possible?

Thanks,
Menno

#1269359

Hi Menno,

As discussed in the chat, here is an example of using the "separator" attribute, for showing some HTML wrapped around a repeating field.

Suppose, you want to show the output like this:


<ul class="list-unstyled mb-7">
<li class="py-3">Responsibility 1</li>
<li class="py-3">Responsibility 2</li>
<li class="py-3">Responsibility 3</li>
</ul>

In this case, we can split the output into 3 parts:

1. The "Before" part:


$before = '<ul class="list-unstyled mb-7"><li class="py-3">';

2. The "Separator " part:


$separator = '</li><li class="py-3">';

3. The "After" part:


$after = '</li></ul>';

To print the final output, these parts can be used with the field's function as:


echo $before.types_render_field("responsibilities", array( "separator" => $separator )).$after;

I hope this helps and please let me know if you need any further assistance around this.

For more personalized assistance around custom code, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

regards,
Waqar