Skip Navigation

[Resuelto] using single layout for 3 pages with conditional cells

This support ticket is created hace 6 años, 1 mes. 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 5 respuestas, tiene 2 mensajes.

Última actualización por Akhil hace 6 años, 1 mes.

Asistido por: Nigel.

Autor
Mensajes
#1131414

Hi Nigel,

I am using layout for

1. Archives
2. Category archives
3. Tag archives

i need to display 3 different cells for the above types of pages.

i will be creating 3 different cells that should be display only when the page is either above conditionally.

what is the best way to approach this ?
3 layout is usual practice, but hard to manage since the archive cell inside is same at all 3 layouts,

is there any conditional code that can be used for this purpose ?

something like this

if page is 'archives' hide cell 2, 3 , if page is ''cat archives' hide cell 1,3 etc, i think jquery ?

#1131417

i got this : https://stackoverflow.com/questions/6374682/jquery-if-this-href-contains

wonder why its not working at the js editor :

( function( $ ) {
$( document ).ready( function(){

$('a[href*="rise-blog/category/"]').each(function() {
    alert('Contains rise-blog/category/');
});
});

#1131940

Nigel
Supporter

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

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

The right approach would be to use Visual Editor cells for these cells, and then wrap the content of the cells in wpv-conditional shortcodes.

You will be testing against a "custom" function (https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/), although you don't need to write any functions (but you must register them), you can use the standard WordPress functions

is_category() (https://developer.wordpress.org/reference/functions/is_category/)
is_tag() (https://developer.wordpress.org/reference/functions/is_tag/)
is_tax() (https://developer.wordpress.org/reference/functions/is_tax/)

If these archives share the same custom archive, you might find it easier to create separate custom archives for each (re-using the same WordPress Archive cell).

#1131963

Yes , its using same archive, is there any setbacks for using many layouts in performance wise ?

Thanks

#1131967

Nigel
Supporter

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

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

No, because you only use one Layout at a time, and the archive cell is just working with the existing query generated by WordPress for the archive indicated by the URL the visitor is on.

If you assign a particular Layout to the category archive then when a user visits the category archive URL on the front end Layouts pops up to say "I'll render the content for this page", and then when it comes to what to render it looks at the archive cell to determine what to render on that part of the page.

It makes no difference that other Layouts may also include the same archive cell.

#1131978

Thank you for the professional detail explanations.
i have in fact created multiple layout.

My issue is resolved now. Thank you!