Skip Navigation

[Résolu] View using custom shortcode not working on new page, but works on existing pages

This support ticket is created Il y a 2 années et 9 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

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

Last updated by Minesh Il y a 2 années et 9 mois.

Assisted by: Minesh.

Auteur
Publications
#2114569

We have a view that uses a registered custom shortcode as an attribute value. This works on other parts of the site, but doesn't work when including the view on new general WP pages built using WP Bakery. If WP Bakery is disabled the view parses fine. Existing pages built using WP Bakery that include the view also still work, this seems to only apply to newly built pages.

The view is called from within a wpv-conditional statement, which uses a custom function to test for a value. If true, display the view. Instead of parsing the view though the shortcode is output without executing.

When the view is called directly without the wpv-conditional it works, but only if there's a hardcoded value for the attribute instead of using the custom shortcode.

URL to test page where the view should be included but doesn't work:
hidden link

URL to an existing page where the view is included and works:
hidden link

URL to edit page in backend:
hidden link

Notes:
- agentcookie() is a toolset-registered custom function that gets a userid value stored in a cookie
- [getagentcookie] is a toolset-registered custom shortcode that calls the agentcookie() function and returns the value

#2114931

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I used the "Fields and Views" button available with the "Text Block" you added and when I add the view's shortcode its been added as given under:

[wpv-view name="agent-branding-for-itineraries" agent="1"]

I can see its working. Can you please try to add view using "Fields And Views" button and check if that help you to resolve your issue.

#2115361

Hi Minesh,

Yes I'm aware that it works if you hardcode the value and don't enclose it within the wpv-conditional — the problem is we can't hardcode the "agent" attribute, it needs to be generated from the custom shortcode. Furthermore, it needs to be inside of a conditional as we don't want to display the view if the custom function doesn't return a value.

- When the view is enclosed in wpv-condition it doesn't execute, it only displays the shortcode.
- When the view is NOT enclosed in a wpv-conditional and has the custom shortcode set as the 'agent' parameter, the server returns a internal 500 error

Something is happening between WP Bakery & Toolset with regards to the wpv-conditional the custom shortcode — but the exact same code is working elsewhere on the site.

Travis

#2116467

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share what shortcode you would like to add with agent attribute and also tell me where you added that shortcode?

#2116583

Here's the block of code that works elsewhere on the site:

{!{wpv-conditional if="( agentcookie() gt '0' )"}!}
{!{wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]'}!}
{!{/wpv-conditional}!}

Both agentcookie() and [getagentcookie] are registered within Toolset frontend content settings and work fine on Content Templates. It's only when I create a new page and use WPBakery that things don't work.
Specifically, the conditional seems to work fine with the custom function but the shortcode within that doesn't execute, it instead displays this on screen:

[wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]']

#2116585

Here's the block of code that works elsewhere on the site:

{!{wpv-conditional if="( agentcookie() gt '0' )"}!}
{!{wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]'}!}
{!{/wpv-conditional}!}

Both agentcookie() and [getagentcookie] are registered within Toolset frontend content settings and work fine on Content Templates. It's only when I create a new page and use WPBakery that things don't work.
Specifically, the conditional seems to work fine with the custom function but the shortcode within that doesn't execute, it instead displays this on screen:

[wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]']

#2116587

Here's the block of code that works elsewhere on the site:

{!{wpv-conditional if="( agentcookie() gt '0' )"}!}
{!{wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]'}!}
{!{/wpv-conditional}!}

Both agentcookie() and [getagentcookie] are registered within Toolset frontend content settings and work fine on Content Templates. It's only when I create a new page and use WPBakery that things don't work.
Specifically, the conditional seems to work fine with the custom function but the shortcode within that doesn't execute, it instead displays this on screen:

[wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]']

#2116589

Here's the block of code that works elsewhere on the site:

{!{wpv-conditional if="( agentcookie() gt '0' )"}!}
{!{wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]'}!}
{!{/wpv-conditional}!}

Both agentcookie() and [getagentcookie] are registered within Toolset frontend content settings and work fine on Content Templates. It's only when I create a new page and use WPBakery that things don't work.
Specifically, the conditional seems to work fine with the custom function but the shortcode within that doesn't execute, it instead displays this on screen:

[wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]']

#2116593

Here's the block of code that works elsewhere on the site:

{!{wpv-conditional if="( agentcookie() gt '0' )"}!}
{!{wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]'}!}
{!{/wpv-conditional}!}

Both agentcookie (custom function) and getagentcookie (custom shortcode) are registered within Toolset frontend content settings and work fine on Content Templates built using Toolset+WPBakery. It's only when I create a new basic WP page using WPBakery that things don't work.
Specifically, the conditional seems to work fine with the custom function but the shortcode within that doesn't execute, it instead displays this on screen:

[wpv-view name='agent-branding-for-itineraries' agent='[getagentcookie]']

#2116609

Sorry for all the replies, the reply form kept reloading without showing my reply so didn't look like it was submitting. You can delete #2116589, #2116587, #2116585, #2116583.

#2118659

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share details where you added the "[agentcookie]" shortcode?

I checked both functions.php file of the theme as well as "Custom Code" section offered by Toolset but I could not able to find it.

#2122587

The url to test is:
hidden link

To see/edit the code of this page the url is:
hidden link

agentcookie() is the custom PHP function.
[getagentcookie] is the custom shortcode based on the agentcookie() PHP function.

#2123027

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes but where you added the custom shortcode [getagentcookie] ?

Can you please share URL of that?

#2123589
Screen Shot 2021-07-23 at 3.08.08 PM.png

It's the link I originally shared 9 days ago and again yesterday.
There are instructions and troubleshooting messages right on the page that I shared that explains everything further.
hidden link

Here is a screenshot showing the shortcode being output instead of executed.

#2124939

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

I get the error webserver is not reachable.

Also, I've a question why you are using so much complicated thing as I can see actually you are storing the value of URL param "mref" to cookie.

You can easily access the URL param value using the shortcode: [wpv-search-term param='mref']
- https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-search-term

Also, I just release a new update for almost all Toolset plugins. We always recommend running your site with the latest stable release plugin version.

*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest officially released version. You can download the latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/

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