Skip Navigation

[Resolved] Collapse / Expand long text inside Block Editor

This support ticket is created 4 years, 8 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 9 replies, has 2 voices.

Last updated by Beda 4 years, 8 months ago.

Assisted by: Beda.

Author
Posts
#1598259
Read_More_Less.jpg

Tell us what you are trying to do?
I created a Product Content Template and inside there is a long post description which I would like to collapse/expand - how can I do this?

I copied a code from a content template created with the Classic Editor but I don't know how to use it with my new template - see attached.

Is there any documentation that you are following? Old Template using Classic Editor

Is there a similar example that we can see?

This is the Old Template: hidden link

This is the New Template: hidden link

What is the link to your site? hidden link

#1599001

There are different ways to collapse and expand.
I guess the easiest is an accordion, or modal to pop up, or a very simple hidden HTML that on click changes class to visible

I'd need to know what your preferences are.

Note, you can always use an excerpt, but that classically will let you link to the post from an archive, for example, so to use it as a teaser for more content.

I don't think that is what you want here, but I'm not sure.
If you need a method to hide large text on a single post and make it visible upon some action, you'd need to define what you prefer, modal/accordion/simple hidden DIV or else.

This will generally require some Custom HTML as Toolset has no accordion or modal blocks.
However, maybe a small addon could do?
https://wordpress.org/plugins/accordion-blocks/

#1599037
collapse.jpg

>If you need a method to hide large text on a single post and make it visible upon some action, you'd need to define what you prefer, modal/accordion/simple hidden DIV or else.

Yes I need a method to hide large text on a Single Post. The old template achieve this by using a comand (#collapseDesc) - see attached.

Is there a way that I can use the same in the Blocks editor? When I click inside the Post Description - it does not allow me to add any code to the text.

#1599053

What is #collapseDesc?
This is not related to Toolset, we do not and did never offer any such ID or structure at all that lets you fold text

The same way it was added to the old template, you can also add it to the new template, for example, using an HTML block, or a Classic or even a Fields and Text Block.

In paragraphs, code can't be added but in HTML Editors, like classic or fields and blocks, you can.

#1599073

So Toolset does not have any function that helps collapse long block of text?

#1599075

No, Toolset has no such feature

In Toolset Layouts there are accordions, but with Blocks and Gutenberg, you wouldn't use Layouts.
In Views or Blocks, there is no such feature.

I've added a request to add accordion blocks.

#1599081

Ok thank you. This would be a useful feature if there are very long fields inside a post.

Let me look into this further..

#1599105

Right now, you will need either an accordion block plugin like shown before, or you could use your existing Code in a Classic, or Fields and Text editor.

#1599185

Ok Re suggestions
Use existing code in Classic Editor - how do I switch back to Classic so that I can add this bit?

Using Fields and Text Editor: The post that I am trying to collapse is a Dynamic Field and I am not able to insert a Fields and Text Editor inside a Dynamic post..please confirm..

#1599195

Hi Gina, please consider the examples I made previously.

1. You can use a Classic Block (by WordPress)
2. You can use HTML block (by WordPress)
2. You can use a Texts and Fields Block (by Toolset)

These 2 things already offer full HTML editing
If more is needed of course you could switch the post type to not use Blocks, for example, but that would effectively disallow to use Blocks, which is not your goal, I understand.

Instead, simply using HTML or Classic or Texts and Fields block will do.

Since you try to hide/collapse content of a dynamic field, you can't use that.
In this case, you need to refrain from using a Dynamic Field and instead can use the "Fields and Views" Button in the "Text and Fields" Blocks, for example, which lets you insert the same dynamic content but with shortcodes.