Hi,
I would like to display the block id for blocks used in the panel in an info section the editor can see. This is so the editor can copy them to use as anchor link tags. Is this possible?
Hi,
I would like to display the block id for blocks used in the panel in an info section the editor can see. This is so the editor can copy them to use as anchor link tags. Is this possible?
Do you mean all block ids of the current page? Yes, you could create a custom page method that outputs all block ids as a list. Just wondering how useful this is with a lot of ids when it’s not clear to which block the id belongs.
Ah sorry I wasn’t clear - my plan was to have an info field in each block template, which would show the block’s id e.g.
This block id is {{ block.id }} - use this for on-page anchor links
No, that’s not possible, you only have access to fields but not to the id. You would have to go via the preview to achieve this, I’m afraid.
Maybe it could also be done with some javascript that appends the id somewhere, ready to copy.
Thanks @texnixe - it might be a nice feature to add, as it would make using the link field really easy for on-page navigation.
I wil give some custom javascript a whirl, that might be the easiest route
Hi,
I have started work on a javascript solution, but seem to have hit an issue already. Just thrown this little test code together:
console.log('Custom panel javascript is running');
let blocks = document.querySelectorAll('.k-block-container');
blocks.forEach((element) => {
console.log(element)
});
I am getting the Custom panel javascript is running message but nothing else. Do I need to wait for some sort of event before running my script? blocks is coming up empty despite there being lots on the page.