Skip Navigation

[Resolved] Unable to insert a dynamic link in the block editor for views

This thread is resolved. Here is a description of the problem and solution.

Problem:

How do I wrap the entire container in a link?

Solution:

You can add two HTML blocks, setup the HTML links, for example:

https://toolset.com/forums/topic/unable-to-insert-a-dynamic-link-in-the-block-editor-for-views/#post-1443831

Relevant Documentation:

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.

This topic contains 8 replies, has 2 voices.

Last updated by henrikG 1 year, 8 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#1441231

Hi

I am trying to create a view where the entire view is clickable linked to the post the view Loop is handling.

But the Toolset Container block is not possible to be clickable.
The only clickable block is the button. So It is not possible to make the entire loop output clickable.

I have tried to insert a button, where the text is dynamic and includes a date and time.

I have a custom post field named "lektion-starter" which is a date time field. and If I try to insert this on the button text like this.

Live d.[types field='lektion-starter' style='text' format='d.m.Y %K%L G:i'][/types]

Then this is what is displayed on the button and not the value of the field (custom formatted date)

hidden link

And If I try to alter the html output, I get a warning (if I wrap the html in a <a herds"[wpv-post-url]"> </a>) and the entire view is messed up. And its not possible to fix afterwards.

So at the moment I can't link to the post if I use the view block editor.

Lots of these issues could be solved if the toolset container could be made clickable. So I could wrap the entire thing in a URL.

#1441877

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

button-front.JPG
button-admin.JPG

Hello,

How do you setup the button block, I have tried it in my localhost with a fresh wordpress installation + the latest Toolset plugins, it works fine.

Here is the screenshot for button block in admin side: button-admin:
Button text: types field='lektion-starter' style='text' format='d.m.Y %K%L G:i'][/types]
Button link: [wpv-post-url]

Test it in front-end, I can see it works just fine, it outputs the button as a HTML link, see screenshot button-front.JPG

#1443309

Hello Luo.

Ok Thanks I thought that adding the shortcode to the button did not work because the output of the button was not renderend in gutenberg, but it was rendered if I used the dynamic setting in the meta box. So the button is fixed.

But how do I wrap the entire container in a link?

#1443831

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

link1.JPG

For the problem:
But how do I wrap the entire container in a link?
You can add two HTML blocks, setup the HTML links, for example:

<a href="[wpv-post-url]">
</a>

Use them to wrap other blocks/contents, see screenshot:
link1.JPG

#1444749

Yes this actually works.

Now is there a way I can drag a toolset container into another container?

Or do I have to recreate everything from scratch, because so far I have not had any luck dragging existing blocks into a container.

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/is-there-a-way-i-can-drag-a-toolset-container-into-another-container/

#1445445

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

I assume the original questions of this thread is resolved, for the new question, please check the new thread here:
https://toolset.com/forums/topic/is-there-a-way-i-can-drag-a-toolset-container-into-another-container/

#1447593

Hi Lou

I made a simple example where I wrapped everything between two custom html blocks as you suggested. And it worked.
Then I remade my view, and it did not work.

I did some investigation and at first I thought it stopped working because I had containers inside containers, but then I discovered (while I recorded a video for you) that it is actually not the container that causes problems, but if you include a toolset button inside the wrapped html, the view rendering gets confused and closes the <a> tag at the wrong location.

Please see this video, and perhaps retry this on your own wordpress installation.

hidden link

And I am sorry for suspecting the container block to be the culprit, when it actually was the toolset button. 🙂

#1447905

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

The Toolset button block will output HTML a element in front-end, for example:

<a class="tb-button__link" href="<em><u>hidden link</u></em>" data-toolset-blocks-button="9412ad3880b10ce70e2fb7202802772e"><i class="tb-button__icon"></i><span class="tb-button__content">Click me!</span></a>

So you can not wrap one HTML a element within another HTML a element , see HTML document:
hidden link

12.2.2 Nested links are illegal
Links and anchors defined by the A element must not be nested; an A element must not contain any other A elements.

#1453079

So its not possible due to html standards.

Thank you.