Skip Navigation

[Resuelto] Possible to have collapse box within body

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created hace 9 años, 10 meses. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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: Asia/Hong_Kong (GMT+08:00)

This topic contains 6 respuestas, has 2 mensajes.

Last updated by jamesG-3 hace 9 años, 10 meses.

Assisted by: Luo Yang.

Autor
Mensajes
#224546

Hi all,

I have a content type loading perfectly and use [wpv-post-body view_template="None"] to load the main content. I would like, if possible, to have only one paragraph of text displayed and have a view more button that would extend the rest of the content below. I had used the collapse-o-natic plugin which works manually, but I am not aware of whether there is a way to automate this? We will have a lot of interns updating the site and they typically forget this.

Thanks!

#224620

Hi jamesG-3,

I suggest you try use Views shortcode wpv-post-excerpt as the "only one paragraph of text",
put [wpv-post-body view_template="None"] in a hidden div,
create a custom javascript to toggle the post body, just for example below test site:
hidden link
user/pass: xgren/111111

Content template using:
hidden link

#224872

Thanks for the idea - the links do not work however for me to check out the source. I have wrapped the body inside an [expand] shortcode and proceeded it with an [excerpt] now. The remaining challenge is how can I ensure that the excerpt shows just the first paragraph and the body skips the first paragraph?

Thanks again!

#225094

It is possible within just Views + Jquery, without other plugins, see the demo page:
hidden link

Please make sure your first paragraph is wrap with HTML <p> tag,

in the content template using below code:
hidden link

<div class="postbody">[wpv-post-body view_template="None"]</a>

js code:

jQuery(document).ready(function($){
  	$('div.postbody p').hide();
  	$('div.postbody p').first().show();
  	$('div.postbody p').first().append('<a href="#" class="collapse-box">view more button ...</a>');
	$('a.collapse-box').on( "click", function( event ) {
		$('div.postbody p').toggle();
  		$('div.postbody p').first().show();
      	event.preventDefault();
	});
});
#225777

Thanks! - where does the JS code actually go in this instance?

#225857

in the content template, click "Open JS editor" button
hidden link

#225876

Awesome - all working perfectly, thanks so much!!!!!

El foro ‘Types Community Support’ está cerrado y no se permiten nuevos debates ni respuestas.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.