Skip Navigation

[Fermé] cred generic field with view shortcode

This support ticket is created Il y a 7 années et 6 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 5 réponses, has 2 voix.

Last updated by Luo Yang Il y a 7 années et 6 mois.

Assisted by: Luo Yang.

Auteur
Publications
#431994

I am trying to use a view shortcode in a CRED generic select dropdown. I am just getting a blank space in the form.

I am pretty sure it's do to the <!-- wpv-loop-start --> markup in the view, but If i delete it, I get an error from Views saying it can't be saved without the markup. So is there a way around it?

View code

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start --><wpv-loop>{"value":"[wpv-post-id]","label":"[wpv-post-title]"},</wpv-loop><!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-layout-end]

CRED code

[cred_generic_field field='_wpcf_belongs_vendor_id' type='select' class='' urlparam='']
{
"required":1,
"validate_format":0,
      "persist":1,
"default":[],
"options":[[wpv-view name='vendor-parent-for-cred-test']]
}
[/cred_generic_field]

Thanks

#432432

Dear adam,

Yes, you are right, the shortcode [wpv-layout-start] ... [wpv-layout-end] will produce an extra HTML div tag, which is for Views filters, paginations and ajax feature, and can not be removed, but you can hide it with a custom shortcode, for example the solution in another thread:
https://toolset.com/forums/topic/unable-to-compare-views-output-in-conditional-output/#post-347444

#432688

That got rid of any markup, but now I have a bunch of whitespace before and after the JSON markup. So it's still not creating the Select field.

I tried to use a php trim() shortcode around the [wpv-layout-meta-html], but it doesn't seem to work.

#432868

Please try this:
1) modify/add the PHP codes in your theme(if you have done this step, you can ignore it)

add_shortcode('hide-it', 'hide_it_func');
function hide_it_func(){
    return;
}

2) modify the Views codes you mentioned above as below, and test again.

[hide-it][wpv-layout-start][/hide-it]
[wpv-items-found]
{"value":"","label":"Choose one"}
<!-- wpv-loop-start --><wpv-loop>, {"value":"[wpv-post-id]","label":"[wpv-post-title]"}</wpv-loop><!-- wpv-loop-end -->
[/wpv-items-found]
[hide-it][wpv-layout-end][/hide-it]
#433129
Capture.JPG

I am still getting whitespace. I changed the view code to 1 line, and that reduced it some, but there is still some present in the picture, and the SELECT doesn't render at all.

I am outputing the VIEW below the [generic_field] just so I can see the output.

[hide-it][wpv-layout-start][/hide-it][wpv-items-found]{"value":"","label":"Choose one"}<!-- wpv-loop-start --><wpv-loop>, {"value":"[wpv-post-id]","label":"[wpv-post-title]"}</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][hide-it][wpv-layout-end][/hide-it]
#433372

Since it needs custom codes, provide a live website with same problem, and fill below private detail box with login details, also point out the problem page URL and CRED form URL, I need a live website to test and debug, thanks

Le sujet ‘[Fermé] cred generic field with view shortcode’ est fermé à de nouvelles réponses.