Skip Navigation

[Résolu] functions in (intermediate) view of many-to-many

This support ticket is created Il y a 7 années et 3 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.

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)

Marqué : 

This topic contains 4 réponses, has 2 voix.

Last updated by Steve Il y a 7 années et 3 mois.

Assisted by: Luo Yang.

Auteur
Publications
#476538

hej toolset.

i do like the 'new' many to many solutions with intermediate post type. i have switched one of my projects containing the working hex2rgb function solution. > https://toolset.com/forums/topic/colorpicker-value-and-hex2rgb/
how can i make the function work in an (intermediate) many-to-many view?

i can display the baisc value with id=$colors addition. but unfortunately with a function this addition doesn't work.

here are some more details about my setup …
'colors' containing wpcf-colors-picker value.
'x-colors' is my intermediate or child post type.
'x-projects' is the other parent post type.
views are set up as recommended in your documentation > https://toolset.com/documentation/user-guides/many-to-many-post-relationship/

thanks in advance for your help!

best,
s

#476822

Dear s,

I assume you are using a view to query the posts of post type 'x-colors', and you are going to display the wpcf-colors-picker value of it's parent 'colors' post, you can try this:
1) Create a content template "x-colors-hex2rgb", with the custom shortcode, for example:

[hex2rgb slug="wpcf-colors-picker" output="hex"]
 
[hex2rgb slug="wpcf-colors-picker" output="red"]
 
[hex2rgb slug="wpcf-colors-picker" output="green"]
 
[hex2rgb slug="wpcf-colors-picker" output="blue"]

2) In the view's loop, add above content template shortcode, for example:

[wpv-post-body view_template="x-colors-hex2rgb" id="$colors"]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body
attributes: id (opt):
'$parent' | 'post-id' | '$custom post name'

#476991

dear luo,

that works good! thanks for your hints.

only trouble remaining is somehow the editor is correcting my code! for example …

<td style="background-color:rgba([hex2rgb slug='wpcf-colors-picker' output='red'],[hex2rgb slug='wpcf-colors-picker' output='green'],[hex2rgb slug='wpcf-colors-picker' output='blue'],0.5)"></td>

… is corrected to …

<td></td>

any idea how to disable this (auto)correction?

best,
s

#477195

I can not duplicate same problem, I tested it in a content template, it works fine. I suggest you try it in a content template too, if the problem still exists, please deactivate other plugins and switch to wordpress default theme, and test again.

Also, since it is a new question, it would be great that you can create new thread for the new question. thanks

#477243

thanks, luo. i will open a new thread.

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