Skip Navigation

[Resolved] Using a view in a content template like a page builder – no posts

This thread is resolved. Here is a description of the problem and solution.

Problem:

Display a content template with PHP codes.

Solution:

Create a content template(ID: 123), design it with blocks editor, setup the static contents.

<?php echo render_view_template( 123); ?>

Relevant Documentation:

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.

This topic contains 36 replies, has 3 voices.

Last updated by martinE-4 8 months, 2 weeks ago.

Assigned support staff: Luo Yang.

Author
Posts
#1526161

Nothing is fixed/ When I remove my "Fake blank" view block the footer problem returns. Try it on the Education page. hidden link

#1526163

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Yes, I did test those URLs you mentioned above in my localhost with your duplicator packages, see the URLs of my above screenshots, I am using below URL to install your duplicator package in my localhost:
hidden link

I did not take out the fake view, only test the URLs, the fake view was already in the content template.

What I see in my locahost is different from yours, isn't it?

For such kind of problem, please provide a live website with the same problem(credentials + FTP access), private message box enabled, thanks

#1526165

hidden link

Here is a live link provided by my LOCAL by Flywheel program. Let me know if you can get in with same user password I already gave in earlier credentials.

#1526473

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the details, I can log into your test site, please provide below details:
Where do you put the custom PHP codes into?

<?php echo render_view_template( 123); ?>

Which one is the content template for website footer?

#1526491

The content template for the footer blocks is 'Footer Template Blocks' id 3025.

The PHP is in the GeneratePress (GP) element 'Footer Content Template' hooked into the entire site with the GP 'before_footer' hook location.

Thanks Luo

#1526651

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I can see the problem after remove the fake view, will update here if there is any found.

#1528215

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Here are what I found, there are some JS missing in outputs of function render_view_template(), and it conducts the problem you mentioned above, I need to check it with our developers for it, will update here if there is anything news. And currently, in your case, the fake view is required.

#1528947

Thank you so much Luo for all your help. I look forward to hearing back. I am proceeding with a staging site and if that would help I could give you the url tomorrow.

#1530403

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Here is the update:

In that page:
hidden link
There are some JS errors, for example:

Uncaught SyntaxError: Invalid or unexpected token

The problem is in that page, Content template javascript is being changed to something, for example:

		var styleTmp = document.querySelector( '.toolset-blocks-styling-tmp' );</p>
<p>	

There are extra HTML p tag in above JS codes, it break the JS function, and conducts the problem, it should be a compatibility issue, some other plugin/theme is changing JS codes, do you have any clue to duplicate the same problem with a fresh WP installation + GP theme/plugins + Toolset plugins?

#1536049

I have been busy getting the site live at icasc.ca It is up now so I'll work some more on trying to help crack this problem. I will create a fresh site and use minimal plugins and GP theme. I will get back to you soon and perhaps I will be able to send you some news or the duplicator package for the site.

#1536179

Hi Luo. I think the problem is my use of the [wpv-autop] shortcode. When I put it in, I have the javascript error and the problem. When I take it out, the footer view displays fine and the javascript error (EOF ...) goes away! (without any need of inserting the 'fake blank' view fix I invented.)

(I was required to use the [wpv-autop] shortcode on a Types Wysiwyg custom field to fix the other bug of no para breaks in a custom field...]

I hope this helps you and the devs track down the problem. Please let me know if you need anything further from me.

#1536349

Further investigation this morning has exposed a 2nd problem with a view interfering with the grid block (it is formatted but appears vertical).

I managed to reproduce this 100% with a SIMPLE fresh site:
using Toolset / and GeneratePress Premium (which has the element hook allowing me to locate my toolset footer content template wherever I wish) - no other plugins except SNIPPETS to put my php code: <?php echo render_view_template( 123); ?>
no custom post types
no content - just 1 page and 1 post

1. Create a new content template in Blocks (using the Views plugin not the Blocks plugin)
2. Content template has only a 3 column GRID block. Put a Toolset Heading block in each grid cell.
No other adjustments to grid.
3. Hook this content template using the php render_view_template code above anywhere below the content (I found it failed anywhere below eg. before_footer, or after_content. If you place it before_content it can show correctly).
4. Create a new page in the Blocks editor using no content template (NONE) and add a simple view which just contains the post title of either pages or posts (or even both pages and posts, it does not matter).
5. The 3 columns fail by showing as 1 under the other (vertical). See uploaded image.

That's it! This is the 2nd problem (100% reproducible).

This may or may not be related to the above [wpv-autop] problem, which I believe is also reproducible.

#1536805

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the details, I am trying to reproduce the same problem with the steps you mentioned above, will update here if there is anything found

#1536871

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I have tried the steps you mentioned above a lots of time(with Views plugin or Blocks plugin), but can not duplicate the same problem, see screemshot: gp1.JPG

The grid block in footer works just fine.

If there are not detail steps to duplicate the same problem, it will be taken as an exception.

Can you provide a duplictor package with a fresh wordpress installation and the steps you mentioned above?
Private message box enabled again. Thanks

#1540259

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Thanks for the details, I am checking it, will update here if there is anything found.