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
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'
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 …
any idea how to disable this (auto)correction?
best,
s
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
thanks, luo. i will open a new thread.