Skip Navigation

[Resuelto] Hide button linked to a type when empty

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

Problem:
How to show or hide custom field when it's empty or does not contain any value within content template

Solution:
View's offers [wpv-conditional] shortcode to display conditional HTML output.

You can find proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/hide-button-linked-to-a-type-when-empty/#post-607418

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#url

This support ticket is created hace 6 años, 10 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Etiquetado: 

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Charles hace 6 años, 10 meses.

Asistido por: Minesh.

Autor
Mensajes
#607364

Support,

I am using the following code:

  <div class="row readmorewrapper">
	<div class="col-sm-5 readmorebutton">
      <h6 class="mtn mbn readmore"><a href="[wpv-post-url]">Read more</a></h6>
    </div>
	<div class="col-sm-5 purchasebutton">
      <h6 class="mtn mbn readmore">[types field='amazon-url' title='Purchase' target='_blank'][/types]</h6>   
    </div>
  </div>

I'd like to hide .purchasebutton if the types field is empty.

Screenshot of current code: enlace oculto

Screenshot of code removed through the inspector (what I'm trying to achieve): enlace oculto

I tried using:
.purchasebutton:empty {
display: none !impmortant}
but that did not work since it contains a H6.

Is it possible to show/hide the .purchasebutton using conditionals?

Thanks,
Chuck

#607418

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Yes - using Toolset you can display conditional output based on your Types field using [wpv-conditional] shortcode.

For example :

<div class="row readmorewrapper">
  <div class="col-sm-5 readmorebutton">
    <h6 class="mtn mbn readmore"><a href="[wpv-post-url]">Read more</a></h6>
  </div>
[wpv-conditional if="( '[types field='amazon-url'  output='raw'][/types]' ne '' )" ] 
  <div class="col-sm-5 purchasebutton">
    <h6 class="mtn mbn readmore">[types field='amazon-url' title='Purchase' target='_blank'][/types]</h6>   
  </div>
[/wpv-conditional]
</div>

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
=> https://toolset.com/documentation/customizing-sites-using-php/functions/#url

#607795

This worked!

Thank you,
Chuck