Skip Navigation

[Resolved] resolving the way a 'view' is displaying when embedded into a post template

This support ticket is created 3 years, 3 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: Africa/Casablanca (GMT+01:00)

This topic contains 19 replies, has 2 voices.

Last updated by Jamal 3 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#2137405
view displaying correctly.png
view not displaying correctly.png

I am building a directory that will pull the 'therapists' who work with a specific issue.

The View (I have built it in a normal page) will show several filter options and allow the visitor to view therapists who work with that issue.

It works fine on the 'page' where it was built, the styling works, the filter (6) appears in columns (3 columns in two rows) and the therapists line up horizontally.

Although the 'View' works when I use the 'template' to build out pages and then use this view although the view correctly embeds in the 'post' it doesn't display as i designed it to.

Question:

What field should I use in the template that I would use to add the correct 'view' to when building each post?
Is this the way to add different views for posts ?

I am building the template as I want a post-relationship between the 'therapists' and the 'issues or subjects' that they work with.

Many thanks

Brian

Is there a similar example that we can see?
yes I have built out the post template and can share this

What is the link to your site?
The site is currently hidden, but I will make it live now and here is the 'page' with the view (it is the view at the bottom of the page)

(by the way it's the same view but I know the subject of the pages differ ... but I was just trying this view on a post template page)

hidden link

Here is the sample post where that view isn't correctly displaying.

hidden link

#2137861

Hello and thank you for contacting Toolset support.

I tried to reproduce this issue on a clean install, and I was not able to. Instead, I have reproduced a different issue, and I think that all is caused by the view's cache. In fact, after I edited the original view inside the content template and saved it, the issue that I have reproduced was cleared, and the view displayed as it is expected to.

I wonder if you would allow me temporary access to your website and let me check the view inside the content template. If yes, your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2138589
view that appears without inserting.png

Dear Jamal

As always thank you for your continued support.

I don't know how far you have got with reviewing this issue but I can now see a further problem, and I don't know if it is linked to some work you have done or a quirk in the system ... but it is directly related to the issue that you are looking into.

As you know I am setting up a website that is basically a directory of 'therapists' who live in specific locations and work with specific issues. The directory will potentially have upwards of 1000 therapists listed.

The purpose of the directory is for 'clients' (people who have an emotional issue and want to resolve it) to search the directory either by subject 'issues' (the problem they are experiencing e.g. anxiety, abuse, anger, abortion, bereavement, etc of which there will be around 100 pages) or by 'location' (where they wish to find a therapist 'Angel, Barbican, Islington, Holborn, Westminster - there will be around 60 locations) or by 'type of therapy' (the style of therapy that might be agreeable to them).

The 'therapist' who pays to join the directory will complete the application form (to create their own profile page), on which there will be sections for them to 'tick' which 'issues' they specialise in (taxonomies) as well as the 'type of therapy', the 'location/s' they work from etc

The 'Profile page' of each therapist will be built as a custom post type as will the 'issues' pages, the 'location' pages and the 'types of therapy' pages.

My intention is to build a highly search or filterable directory with post relationships to make finding exactly the therapist that a client wants to work with easliy.

The core way people 'find' a therapist is by going to the individual 'issue' page that interests them e.g. anxiety, anger, abuse, abortion, grief, depression etc

On the 'issues pages' (the problem they want to solve) I want there to be a search function to show therapists who work specifically with that issue (and this will be built using a view with a query filter that ensures that only therapists who work with that specific issue will show in the view results).

I have successfully done this on 'pages' where I built the view.

However the reason I got in touch yesterday was that when i 'insert' the view into a post, in the section set up for me to insert a 'view' although the 'view' works it didn't display properly in that the columns were ignored and the search results were not displaying correctly on the page (the right results but not styled)

So that is why I contacted you yesterday.

Since then i decided to go ahead and start populating my 'issues pages' with a view to 'adding in the correct 'views' once they were correctly showing.

I noticed that even when I built and saved a new 'therapies for' post without entering any information into the custom fields, I would see the same 'set view' appearing at the base of the page ... here is an example on the 'abuse counselling' page

hidden link

you will see that although none of the custom fields are popluated on the back end, the view for 'addictions therapists' is showing on the front end.

It looks like this has be hard coded into the page somehow?

So this is where I am with this issue.

I look forward to your response.

#2139345

Hello @brianC-15

I am sorry, but I am not sure what the question is? I understood that you don't see why the view is displayed on that therapy-for post(Abuse Counselling in London), right?
If that's the question, I am keen to think that the view was added to the "template-for-therapies" content template. The content template is assigned to the "therapy-for" post type. So, it will be used to display a single post page like hidden link
Unless there is another content template that is assigned to the post type with different conditions and priority.

I can't really tell, without taking a look at the website's admin area.

If this is not the question, please elaborate more about it. May be explain it in steps, like:
1. I go to xxx
2. I do xxx
3. I expect to have xxx
4. Instead, I get xxx

#2139435
step 1.png
Step 2 create custm post.png
step 3 leave all fields blank.png
Step 4 publish.png
Step 5 the field is inserted without me doing it.png

Hello Jamal

I am sorry if I have confused things.

The above is a description of how the website is being built ... to make sure that you are clear that there are several custom post types: Therapists (profiles), Therapy for (the individual issues), Locations (not built yet but will be a custom post type for the clinic location)

So my original ticket for support ... the first thing I asked for help with was that when I build a 'view' so that I can display therapists who work with one specific issue e.g. Abuse I then want to be able to insert that specific 'view' on the custom post page built for the subject 'Abuse'.

There will be around 100 individual 'therapies for pages' built using the 'custom post type' 'Therapies for'
So eventually I will have a custom post page for 'Abuse', 'Anxiety', Anger', 'Abortion', Addiction and so on

There will be a corresponding 'View' built for each of these pages which will have a custom query to ONLY show therapists who have say 'Abuse' ticked in the taxonomy linked to their profile page, so they may work with lots of different issues ... Abuse, Anxiety, Anger etc and when a 'Client' visits the 'Abuse' page, or the 'Anxiety' page or what ever the issue is in the page, when they see the section called
Therapists who work with .... they will see the result of the 'view' built for that subject e.g. 'Abuse, 'or the page on Anxiety will have the view embedded for 'Anxiety.

So at the moment when I go to build a new issues page using the custom post type 'Therapies for' you will see that in the 'fields there is nothing entered but if i were to save a blank (nothing entered int he custom post fields ... and hit save when i view the page there is a view being inserted that I have not added ... and its' always the anxiety view!

Here are the steops to see what I mean ...

I am going to create a brand new post called 'Test the custom post type' but i won't add anything in the fields and then I will hit save and show you the output.

1. I go to the wordpress admin panel and to the side bar and select the 'Therapies for' custom post type
2. Step 2 name the page Test Custom Therapy Issues page
3. Step 3 do not add anything to any of the custom fields
4. Step 4 Publish it
5. Step 5 when you view you see that although I didn't add in a view there is a view and it is for the addictions therapists

#2141791

The view appears because most probably it is being used inside the content template that displays the post. Please distinguish between custom fields, taxonomies, etc.(the data) and how it will be displayed(the content template). I am sure that the content template that is picked to display the post includes the view, so I would expect to see the view whether I added data to the post or not.

Can I login to your website and check this closely? Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2142089

The view continues to appear on single post's page because it is being used inside the content template that displays those posts. Check the following screenshot, it is taken for the content template that is used for the "Therapies for" custom post type.
hidden link

Regarding the styling issue, I can still see the issue on this page. I'll need to take a copy of your website and analyze it locally. Would you allow me that?

#2142131
view not displaying correctly.png
view displaying correctly.png

Dear Jamal

Of course .... I am so sorry i realise that I built the view in the 'custom template' ... and of course it would keep on showing it. I'm really sorry that I didn't see that straight away ... thank you for helping me.

So the second problem is to work out why the styling of the view is not working.

All the views i have built have had the images running horizontal and the filters styled in three columns, but when they pull in dynamically to the page the images are vertical and the filters take the whole width of the page ... for some reason, the view styling isn't displaying when the custom post displays

If you can advise me that would be great.

#2142505

I need to take a copy of your website and debug it further. For example, I'll check how does it work when only Toolset plugins are involved, and with a default theme. I'll also check on our online platform to exclude any possibility of a caching system.

And if I don't find the cause behind that, I'll escalate the copy to our 2nd Tier for further analysis.

I can't take a copy of your website without your approval. And I'll use a 3rd party plugin to take it. Do you allow me to take the copy?

#2142679
1.png
2.png

Dear Jamal

Thank you again for your continued support.

Since yesterday I have done a lot of tidying up on the site back end.

I have deleted many of the older'views' that I built and decided to try and see if building a brand new view,ONLY using toolset blocks and then applying this on a Custom post would solve the issue.

It didn't.

So below are the two screenshots of the same 'view' that I built on the following static page where it displays correctly with all the styling in place.

The view is called 'Addiction Therapists In London' and is only appearing on the following two pages:

hidden link (.... this is a standard static wordpress page)

Now, here it is on this custom post page (pulled in as one of the custom post fields) where it doesn't display correctly

hidden link ... this page is built using the 'Template for therapies' that pulls in the custom fields, one of which has the shortcode of the 'view' embedded)

I am happy for you to take a backup of the website, I have my own backup should anything go wrong.

If you can find out why the styling isn't working that would be great.

Image 1 shows the correct view that displays on a static page.
Image 2 shows the view NOT DISPLAYING correctly on a custom post page

All the best

Brian

#2143107

Hello Briand, there are actually a couple of limitations that have contributed to this issue. One of them is most probably a bug. But, I managed to find workarounds for each of them.

1. The first one is a known issue with the GenerateBlocks plugin. You can read more about it in this article https://toolset.com/errata/generateblocks-styles-lost-on-front-end-when-using-content-templates/
This appeared for the search filters of the view because they are wrapped inside a GenerateBlocks grid, and we need to add the custom code to fix it.

2. The second issue is that the view's loop grid is lost when the view is being reused in a blocks' content template. But, I found a workaround about it. It consists of adding the view block, then editing it by clicking on the "Edit Original View" button, and just saving without performing any modification. Check this screenshot hidden link
I already encountered this behavior on my test site and it smells like a usability bug. I'll escalate this to our 2nd Tier for further analysis.

3. Now, because you are adding the view inside a WYSIWYG field using a shortcode, we can't really apply the above workaround. So, I created a content template using the blocks editor and I added the view inside of it. I applied the above workaround(edit original, then save). Then I added the content template to the WYSIWYG field using a shortcode and I removed the view's shortcode. Check this screenshot hidden link
Please note that this content template is not assigned to any custom post type. So, it will not be used to display the single post page.
hidden link

Unfortunately, if we don't add the view to the content template "Template for Therapies", the custom code in issue (1) won't work as expected. And we'll need a more elaborate workaround.

Let me first ask about your use case, especially, why are you trying to add the view inside of a WYSIWYG custom field using a shortcode, instead of adding it to the content template?
If that's not required, we can add the view directly inside the content template and let the custom code fix it.

Otherwise, we'll need to add the view to the content template to make the code work. And hide it using CSS or Javascript so it does not appear one more time to the user.

Please let me know your answer so we can fix the search filter styling. In the meantime, I disabled the search filter for the view inside the new/intermediary content template. Check this screenshot hidden link

#2143611

Dear Jamal

Once again thank you for your patient response and clear explanations. I really do appreciate the hard work you have put into trying to help me with the issue.

So let me say first that I am rather relieved that the issue I am experiencing isn't just my lack of understanding but something more to do with a bug or technical difficulty.

Before I answer your questions and add any further information can I ask a simple question?

If I were to move away from using GeneratePress as my theme (building of pages) and use perhaps Astra or Ocean or one of the other themes (page builders) that Toolset recommends, would this solve the problem?

If it would then I am happy to go this route rather than trying to add workarounds that may potentially cause further issues or not resolve all the issues.

I only chose GeneratePress (and Generate Blocks) because it was one of the recommended themes (by Toolset ... I'm not blaming you at all) when I was learning to use Toolset last August it was the one used in the videos, so I thought 'OK I'll use 'GeneratePress'.

I am just about to renew my licence for GeneratePress so if Astra or Ocean would work without the bugs etc then I could go that route.

So now to your Questions.

If you don't mind I'll clip a bit of your message so that you know what I am answering.

1. Using WYSIWYG
Your Question:
Let me first ask about your use case, especially, why are you trying to add the view inside of a WYSIWYG custom field using a shortcode, instead of adding it to the content template?
If that's not required, we can add the view directly inside the content template and let the custom code fix it.

My Answer:
I only used it because I needed a field to add in the 'View shortcode' but also I thought I might add in the heading as well ... so I didn't use it for any particular reason and in fact in my very first message to you I did ask

"What field should I use in the template that I would use to add the correct 'view' to when building each post?
Is this the way to add different views for posts ?"

2. Adding the'View' to the Content Template:

You said
Otherwise, we'll need to add the view to the content template to make the code work. And hide it using CSS or Javascript so it does not appear one more time to the user.

Do you mean add a 'specific' view so that it appears in every 'custom post' ... doesn't this mean that the 'same' view will appear on every post page (therapies for) with the same filter / custom query filter ...

This wouldn't work for my site, if this is what you mean.

Let me just be really clear ... every page built using the custom post template 'Therapies for' will be unique.

Each of the posts built using this custom post type will be focused on a 'subject' or 'issue' that the client is looking for a specific therapist who works with THIS issue ... to help them.

So when Therapists sign up they will tick 'taxonomies' for the issues they work with e.g. anger, anxiety, abuse, depression, stress, bereavement etc ... there are around 100 issues

I will be building a view, each with its own 'query filter' that will use just one of the taxonomies e.g. Bereavement.

So when the client lands on the post page 'Therapy for Bereavement' (built using the 'Therapies for' template) and they see the 'view' (list of therapists) they are only presented with therapists who ticked the taxonomy 'Bereavement' and they can further filter by 'gender' 'location' 'day of the week' etc ... but only those therapists who work specifically with 'bereavement' will appear as a result in the view.

This will mean that there are about 100 views that I will build and each needs to appear uniquely on the right 'Therapises for' post hence the need for this custom field to allow me to choose the correct view when building out each post page.

I hope I am being clear.

I really look forward to hearing your answers.

Regards

Brian

#2143673

Hello Brian,

Well, the issue with GenerateBlocks does not really concern the theme GeneratePress, but it has to do with how GenerateBlocks enqueue their styles. GenerateBlocks scan the content of the current post(either page, post, or custom post) and if it includes any GenerateBlocks' blocks, it adds its styles.
So, once you use GenerateBlocks's in a Toolset element(view, content template, or archive), it will most probably need the custom code to get the proper styling for GenerateBlocks.
Honestly, I would recommend using Toolset Grid instead of GenerateBlocks grids inside of Toolset Views.

And regarding the use of views inside custom fields, I still think it is not a good idea. Why? Because fields should hold data, not logic or design. A view is basically two things, a logic that determines what posts to query, and a design to display these posts. Honestly, I don't think it is a good idea to use a view/content template inside of custom fields. The main principle, behind it, is custom fields should hold data.

This being said, I must suggest what to do to display filtered views based on the current post(therapy for), right? That's possible through the query filter. Instead of specifying what taxonomy terms, you can let Toolset pull them from the page(post) where the view is shown. Check this screenshot hidden link

Adopting this will let you build one view that should work for all the taxonomy terms instead of building 100 views for each issue/speciality. Does it make sense?

Finally, I'd like to kindly ask you to handle this case(a filtered view based on where it is displayed) on another thread instead of this one. Let's keep this one about the design of a view when used elsewhere. I hope you would agree!
You can ask for me on the new ticket, and my teammates will pass it over to me.

#2143691

Hello Jamal

I understand about the need to keep threads on one subject.

So I will open a new thread to continue to ask for help with regard to 'views' filtered for specific taxonomies.

But on the issue of styling ... basically you are saying ... stick to GeneratePress, but don't use GenerateBlocks to build out the custom post ... this is where I am getting lost!

Do you mean I should perhaps remove the GenerateBlocks plugin and only design in GeneratePress and Toolset blocks?

If yes then I understand, if no then please explain how I don't use Generate Blocks for building out custom posts but do for other pages?

I will open a new thread for the other part of my work on views ... as i don't understand what you are suggesting with regard to pulling in taxonomies from the page

Regards

Brian

#2143725

My apologies, Briand, for the confusion. That's not really what I meant.

We are committed to helping our users with any themes or plugins they are using. Especially the popular ones and those that we recommend.

What I meant is, if you don't want to use workarounds for fixing GenerateBlocks styles, then, do not use them inside Toolset Elements(Views, Content template, Archive templates).
You can keep using them on regular pages, or in custom posts contents. But, if you use them in Toolset Elements, then the workaround will be required.

I can agree that this is a usability bug that should be fixed, either on Toolset or on GenerateBlocks. Right now, we are offering a workaround, because we can't afford development efforts if the issue is affecting few users. If the issue is reported by several users, then we'll definitely fix it or we'll collaborate with the GeneratePress/GenerateBlocks teams to fix it once for all. Does it make sense!

Honestly, I would not recommend installing themes/plugins that do not offer something more(in terms of blocks) than what WordPress and Toolset already offer. For example, in this case, I would suggest using the Toolset Grid block instead of GenerateBlocks Grid, unless you are looking for a feature that the Toolset Grid block does not have.