Is it possible to filter out the html in a block label?
Here’s my current block blueprint…
name: Intro
icon: headline
label: "{{ text }}"
fields:
text:
type: writer
Wondering if it could be something like the below. If I use the below, it doesn’t show any preview text.
name: Intro
icon: headline
label: "{{ text.inline }}"
fields:
text:
type: writer
related: Showing block field info as label
I believe you need to setup a page model for this to process the text.
With something like this in the model.
<?php
class YourPage extends Page {
public function stripText($txt) {
return Str::unhtml($txt)
}
}
Which should allow you to use it in the blueprint:
label: {{ page.stripText(text) }}
1 Like
texnixe
February 15, 2023, 5:43pm
3
I’m a bit surprised that this should work, because this is just a string template replacement where you cannot use query language.
Reading the docs for the Query language says you need to set up a page model to use a custom method in the query language. I just went with that. You dont think that will fly?
texnixe
February 15, 2023, 5:57pm
5
No, because this label is never evaluated as query language. It’s used here in BlockTitle.vue
using a string template:
const label = this.$helper.string.template(
this.fieldset.label,
this.content
);
Similar to how you can use strings like {{ placeholder }}
in markdown or so to be replaced with your company name using Str::template()
.
So actually this needs to be done on the Vue side of the fence? Like override BlockTitle.vue
or something?
texnixe
February 15, 2023, 6:13pm
7
If that’s possible, then yes. It cannot be done via the blueprint. I was just surprised that this was marked as solved.
I assumed it would work because @jimbobrjames does good work
@texnixe is there a real solution for this?
texnixe
February 16, 2023, 8:51pm
10
Create a proper preview, or
use the text field preview.
name: Intro
icon: headline
preview: text
fields:
text:
type: writer
Or use the writer field in inline mode.
inline: true
if only a single para is supposed to be used.
Inline mode made the label work. Thank you so much!!
1 Like
@lukehatfield glad it got solved in the end. Sorry for the red herring.