Skip Navigation

[Resuelto] layouts/views content template, layout template

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
What is the difference between Views Content Templates and Layouts templates and which one should be used with Divi.

Solution:
It is recommended to use Views Content Templates with Divi and to not use Layouts.

For a fuller discussion of the difference between Content Templates and Layout templates see the answer below: https://toolset.com/forums/topic/layouts-views-content-template-layout-template/#post-618575

This support ticket is created hace 6 años, 9 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Este tema contiene 6 respuestas, tiene 2 mensajes.

Última actualización por lauraC2426 hace 6 años, 9 meses.

Asistido por: Nigel.

Autor
Mensajes
#618368
5.jpg
4.jpg
3.jpg
2.jpg

Hi, I've created a CPT and I now want to edit how it's displayed, so basically the single-page of this CPT. I've followed this as I am using Divi https://toolset.com/documentation/recommended-themes/toolset-divi-integration/create-templates-for-custom-post-types-with-divi-builder-and-toolset/
My first issue is that I am using wordpress in French so I have toolset in French as well and I am not sure what content template refers to. I guessed "modèle de contenu" so I made one related to my CPT but nothing appears enlace oculto what is wrong ?
I also have "mise en page" which I guess refers to "layout template" but I can't understand the difference between the 2, even after reading threads about it in the support.
Many thanks in advance !

#618575

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi Laura

I'm not sure what French translations Toolset uses for terms such as Content Template or Layouts. You may find it easier while working on this part of your site to edit your profile and specify English as your language (just the language you see, not the site language) so that what you see on your site matches what you see in the documentation.

Let me briefly describe the relationship between Layouts and Views templates and then you ask me again once you have understood and you are still not seeing what you expect to see.

So, when you view content on the front-end, how it appears is normally determined by your theme, which uses different PHP templates to generate the output, depending on what is being displayed.

For posts, including custom types of posts, the theme will normally use a template single.php to generate the output.

Now, if you have added custom fields to your posts, which your theme doesn't know about, and you want to output them then the first option would be to edit the single.php file and add the PHP required to show such fields where you want them.

But you don't want to write PHP, which is where Toolset comes in.

The next option is to use Views.

Views lets you create Content Templates where you insert the fields, both standard fields and custom fields, taxonomy terms etc., where you want them.

When you assign such a template to a post type what happens is that when the theme renders the output for that post using single.php Views intervenes and swaps out what the theme would render and replaces it with what you have designed with your Content Template. (It is actually only replacing the part of the output that the theme renders using the_content() function.)

Layouts are an alternative way of doing the same thing, and you would do one or the other. Layouts is a page builder and so it gives you some more control over the placing of content within your template, e.g. in columns or a grid. It is nothing you can't achieve with a Views Content Template and the necessary CSS, but provides a more visual way of constructing the page. They are otherwise the same. If you try to assign both a Template Layout and a Content Template to the same post type, Layouts wins.

Now, when you add Divi to the mix, the first point to note is that we suggest you do not use Layouts. Divi has a page builder, Layouts is a page builder, and two page builders invites problems.

There is also an additional complication that Divi CSS conflicts with Bootstrap CSS (which Toolset uses, especially Layouts), and so we recommend you disable Bootstrap at Toolset > Settings.

That said, the expected use of Toolset and Divi is that you would create a Content Template using Views that you assign to the post type in question, and you may optionally design that template with Divi if you like working with the modules it offers. When you want to add custom fields to the template you would need to insert them into a Divi text module in this case.

In light of that, let me know if you still have any questions.

#619179
2.jpg
1.jpg

Thanks a lot Nigel, I've understood. So I created the content template but it didn't appear on my CPT single page. I removed the layouts plugin and then it worked. So I guess layouts is forbidden/useless with Divi?
However there is an issue with the "disable elements" section. If I don't disable the title I have it twice, the default title and the title that I put myself with a divi module (for better styling). But if I disable it, both disappear... except for the meta of the original title though.
How to make it work please?
Thanks!

#619630

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi Laura

You can disable the post meta by going to the Divi theme options (Dashboard > Divi > Theme Options > Layout) and turning off each individual component (e.g. author, date etc.).

The Toolset Divi theme options don't have a section for this, you need to set it globally in the Divi options.

As for the post title, if you disable the post title and that also disables the post title module you inserted into your template then I suggest you insert the title with a text module—styled as you like—instead. Divi must interpret the setting to disable the title to not only disable the title inserted by the theme template but to disable the title module, too.

The presence of Layouts on the site shouldn't affect how your Content Templates work unless you have a Layout that is assigned to the same post type.

#619643

Thanks Nigel, the 2nde option works, I've used a text module and put the shortcode of the post title in there.
For the 1st option it's not what I want as it removes the meta from all types of posts while I just want it gone for this CPT, as this is kind of a page type of post. But I do want to keep the meta for my regular blog posts.
Thanks

#619657

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi Laura

There isn't a theme option setting to disable the post meta (I don't know why that wasn't included, I have filed a request for it to be added), so you will need to hide it with CSS.

In the custom CSS section of your Content Template add the following:

.et_post_meta_wrapper .post-meta {
  display: none;
}
#619677

Okay that way it works, thanks a lot !