Skip Navigation

[Resolved] JS errors being generated in CPT archive layout

This support ticket is created 4 years, 9 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/Hong_Kong (GMT+08:00)

This topic contains 10 replies, has 2 voices.

Last updated by rangesT 4 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1515629

Tell us what you are trying to do?
Creating a custom post WordPress archive page with a content template using CSS Grid as the layout.

Is there any documentation that you are following?
No, just using an unformatted Loop display but experiencing errors in creating the loop and in the layout display itself (grid layout skipping cells). Wonder if Views plugin is corrupted somehow?

Is there a similar example that we can see?
N/A

What is the link to your site?
hidden link

#1515837

Hello,

What JS errors are we talking about? please copy the error logs here.
Are we talking about Toolset Layouts plugin? Are you going to add a WordPress Archive cell into the layout?
https://toolset.com/documentation/user-guides/layouts/wordpress-archive-cell/

I have tried it in my localhost with a fresh WordPress installation + the latest version of Toolset Plugins, it works fine, there isn't the same problem as you mentioned above.

I suggest you check these:
1) Make sure you are using the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate all other plugins, and switch to wordpress default theme 2020, deactivate all custom PHP/JS code snippets, and test again

3) Also check if there is any PHP/JS error in your website:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/

#1516059

Thanks Luo -

I have updated the Toolset plugins to their latest versions.

I'm not using layouts at all - in fact I have removed it from my site in favour of the new views/blocks functionality which is working well aside from this issue.

The specific issue that I'm having is on the archive page hidden link - you can bypass the landing screen by clicking the black key in the bottom right corner and entering RangesStaging as the passphrase.

The behaviour I expected is in the CSS Grid under the filter flowing all items into the row in sequence - though when the page is loaded, the grid skips every second cell.

Weirdly, when you click either forward, reverse or reset in the filter - the Grid behaves as expected.

The JS errors that I'm seeing are specifically on the business archive page:

(index):1161 Uncaught SyntaxError: Unexpected token '<'
(index):1188 Uncaught SyntaxError: Invalid or unexpected token
(index):1226 Uncaught SyntaxError: Unexpected token '<'
(index):1253 Uncaught SyntaxError: Invalid or unexpected token
(index):1291 Uncaught SyntaxError: Unexpected token '<'
(index):1318 Uncaught SyntaxError: Invalid or unexpected token
(index):1356 Uncaught SyntaxError: Unexpected token '<'
(index):1383 Uncaught SyntaxError: Invalid or unexpected token
(index):1420 Uncaught SyntaxError: Unexpected token '<'
(index):1447 Uncaught SyntaxError: Invalid or unexpected token
(index):1485 Uncaught SyntaxError: Unexpected token '<'

The specific toolset related PHP errors in the last month or so are:

[30-Jan-2020 07:21:11 UTC] PHP Notice: Undefined property: WPCF_Repeater::$order_meta_name in /var/www/ranges.directory/htdocs/wp-content/plugins/types/vendor/toolset/types/embedded/classes/repeater.php on line 151
[30-Jan-2020 10:18:45 UTC] PHP Notice: Undefined property: stdClass::$provider in /var/www/ranges.directory/htdocs/wp-content/plugins/toolset-maps/application/controllers/compatibility/gutenberg/editor-blocks/blocks/map/MapBlock.php on line 490
[30-Jan-2020 10:18:45 UTC] PHP Notice: Undefined property: stdClass::$source in /var/www/ranges.directory/htdocs/wp-content/plugins/toolset-maps/application/controllers/compatibility/gutenberg/editor-blocks/blocks/map/MapBlock.php on line 492
[30-Jan-2020 10:18:45 UTC] PHP Notice: Undefined property: stdClass::$field in /var/www/ranges.directory/htdocs/wp-content/plugins/toolset-maps/application/controllers/compatibility/gutenberg/editor-blocks/blocks/map/MapBlock.php on line 493
[15-Feb-2020 06:10:22 UTC] PHP Notice: Undefined property: WPCF_Repeater::$order_meta_name in /var/www/ranges.directory/htdocs/wp-content/plugins/types/vendor/toolset/types/embedded/classes/repeater.php on line 151

#1516093

Have you checked the comaptibility issue? See my first answer above:
https://toolset.com/forums/topic/js-errors-being-generated-in-cpt-archive-layout/#post-1515837

If the problem still persists, please provide a database dump file of your website in below private message box, I need to test and debug it in my localhost. Thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1517403

Thanks for the details, I am checking it in your staging site, will update here if there is anything found

#1517451

Here are what I found:

It seems there are other plugins/theme in your website appling the_content fitler into content template, and conducts the problem, I have done below modifications in your website:
Edit the WordPress archive "Businesses":
hidden link
In section "Loop Editor", change the shortcode from:
[wpv-post-body view_template="loop-item-in-businesses" ]
To:
[wpv-post-body view_template="loop-item-in-businesses" suppress_filters="true"]

Test it in front-end:
hidden link
It works fine.

More help:
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-body
suppress_filters (opt):
'true' | 'false' (default)
If suppress_filters=’true’, all third party (non WordPress) filters hooked into the_content filter will be removed, when retrieving the post body.

#1517453

Okay thanks for the update Luo - I can see the grid layout working on the front end - thanks!

I have one more issue with the site which may or may not be unrelated to the same underlying issue.

When I switched off the Pro theme - the problem still existed in the business archive grid. Pro is the only other entity in the build that would affect the archive templates and be calling "the_content"

The other thing that makes me think there is a corruption somewhere is the fact that the loop wizard in the Groups archive page won't allow me to create a content template - with or without the Pro theme being active.

Is it worthwhile replacing the views plugin files do you think?

#1517457

For the new question: Is it worthwhile replacing the views plugin files do you think?
Are we talking about upgrading Toolset Views plugin?

If it is, it is recommended to upgrade Toolset plugins to the latest version, and according to our blog post:
https://toolset.com/2019/11/toolset-views-becoming-toolset-blocks/
“Toolset Views” Becoming “Toolset Blocks”

We recommend to use the "Toolset Blocks" plugin instead of "Toolset Views" plugin in your future projects.

#1517499

So I've deactivated views and replaced it with blocks - no ill effects in the staging site which is comforting...

However I'm still having the issue that the loop wizard won't create a content template for the 'Group' archive items.

The JS error that I see is:
Uncaught TypeError: Cannot read property 'setValue' of undefined
at WPViews.LayoutWizard.self.process_layout_wizard_data (views_layout_edit_wizard.js:604)
at HTMLButtonElement.<anonymous> (views_layout_edit_wizard.js:1193)
at HTMLDocument.dispatch (load-scripts.php:3)
at HTMLDocument.r.handle (load-scripts.php:3)

Hopefully this is something simple! I'm still concerned that I have a larger problem with the toolset code or config somewhere...

Edit: I just managed to make the loop wizard work on 'archive for groups' - perhaps it's an issue with just that archive... I'll keep pushing on - perhaps we close this off for now.

Thanks for your work.

#1517517

Maybe it is a browser cache problem, I suggest you clear your browser cache and test again, please let me know if you need more assistance for it. thanks

#1517741

still some gremlins but I can move forward