Hi!
I'm setting up a new project website where I will share tutorials of what I've learned and one thing I want to do is copy and paste code in to the Grid Layout I have. I thought I could just use the built in <> Code option within the Grid Layout but I've stumbled upon and issue. It shows razor code fine but as soon as I put in any html e.g.
<ul> tags
<a href=""> tags
and similar it converts them and make them in to lists, links etc.
I've since found what I'm trying to do is prevent the Grid Editor 'Code' from rendering html tags and just show them as text.
Still not found the solutions but hopefully that explains what I'm trying to do a bit better?
Hi,
I tried this and it works in the backoffice but on the frontend it still renders everything as HTML e.g. if I put a something I will just get the word something displayed as a link.
The pre tags are around it but it doesn't seem to make any difference.
Hi
After some testing over the weekend it seems that if I use the <> CODE button to choose type of content, it renders the HTML code as a link or a paragraph etc. which is what I didn't want. If I however type the code in to the RTE option and style it with my 'code' css, it works perfectly. At least I have an option now for typing code in to my blogs. Not sure why one works and the other doesn't. I'll look into that at a later date.
HTML code within Blog post
Hi! I'm setting up a new project website where I will share tutorials of what I've learned and one thing I want to do is copy and paste code in to the Grid Layout I have. I thought I could just use the built in <> Code option within the Grid Layout but I've stumbled upon and issue. It shows razor code fine but as soon as I put in any html e.g.
and similar it converts them and make them in to lists, links etc.
How can I get around this?
Thanks,
I've since found what I'm trying to do is prevent the Grid Editor 'Code' from rendering html tags and just show them as text. Still not found the solutions but hopefully that explains what I'm trying to do a bit better?
Output using @Html.Raw(Model.Content.GetPropertyValue
Obviously there is inherent danger in not escaping user generated content...
HTH
The easiest thing to do in my opinion is to make a new grid editor in the config/grid.editors.config.js file and add a pre tag to its markup
add the following entry
You should now have a Code option when adding new content to a row in the grid.
The style part is how it gets rendered in the grid in the backoffice.
To style it on the page use the included codeblock class.
More information can be found on: https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/grid-layout/build-your-own-editor
Hi, I tried this and it works in the backoffice but on the frontend it still renders everything as HTML e.g. if I put a something I will just get the word something displayed as a link. The pre tags are around it but it doesn't seem to make any difference.
O.
When I render the grid like this:
@Html.GetGridHtml(Model.Content, "grid")
I get the following
Hi After some testing over the weekend it seems that if I use the <> CODE button to choose type of content, it renders the HTML code as a link or a paragraph etc. which is what I didn't want. If I however type the code in to the RTE option and style it with my 'code' css, it works perfectly. At least I have an option now for typing code in to my blogs. Not sure why one works and the other doesn't. I'll look into that at a later date.
Thanks for your help everyone!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.