HTML Block messed up my page

Permalink 1 user found helpful
Hi, I added an HTML block to my page, but even though the page shows up (a little messed up) I'm unable to edit blocks on the page. Clicking on blocks just won't pull up edit menus anymore. I want to remove the recently added HTML block (this causes the error) but I can't do that either. Going back to a previous version doesn't seem to work either.

Somebody, please help!

Thank!
Luca

ZillionProductions
View Replies: View Best Answer
hutman replied on at Permalink Reply
hutman
If you can't use the previous versions the only real way to undo this is to dig into the database and remove the offending code.
zaneweb replied on at Permalink Reply
zaneweb
Expanding on what @hutman said, if you have FTP, SFTP, or SSH access to the server the code is hosted on, I would manually edit the code to try and find it.

If you are unsure of what file the code is in, I would run this command on your server.

grep -r -H "[sample of whatever code you wrote here]" *

That will perform a server search for that text in any file. If you want to search a specific file, replace the * at the end with the filename or path to filename.

Don't forget that concrete5 may split up chunks of the code. It is unlikely, but still possible, therefore a smaller sample size of the code you wrote may be better.

Anyway, after that just remove the code, making sure to be careful about the other code that already exists.

Hope this helps!
SnefIT replied on at Permalink Best Answer Reply
SnefIT
Luca,

I think that the problem is caused by invalid HTML (forgetting closing tags?) or some CSS that conflicts. So my advise would be to dive in to the database and lookup the content of that specific instance. Change the content in a simple DIV with some text (so you can see it in edit mode easily). After that, I think you should be able to edit the page again.
Curretly I can't lookup the exact tables for you, but I think you will find it anyway (you can find the block ID (bID) in the HTMLsource).

Let us know!
ZillionProductions replied on at Permalink Reply
ZillionProductions
Thanks SnefIT, this really worked perfectly for me. Problem solved!
JohntheFish replied on at Permalink Reply
JohntheFish
If you go directly to the sitemap in the dashboard, in most cases you can revert the page version to the one before you added broken html. Much easier and safer than hacking the database.

There are also block templates for the html block that don't render in edit mode, so allowing you to always get into the page in edit mode. If you assign such a block template before entering html it will keep you safe.
ZillionProductions replied on at Permalink Reply
ZillionProductions
Hi John, thanks for your reply. Editing directly in the database did the job for me. However; I'm curious to know what 'block templates' you are talking about. Maybe it can help out others who don't want to make changes directly in the database.

Thanks!
JohntheFish replied on at Permalink Reply
JohntheFish
The technique is described here.
http://legacy-documentation.concrete5.org/tutorials/prevent-an-html...
Equally applicable to 5.7 and v8.
I cant remember off hand where the pre-prepared templates are.
JohntheFish replied on at Permalink Reply
JohntheFish
While there are such templates on github etc, I couldn't find any in the marketplace, so quickly submitted one to the PRB. It will be free and hopefully reviewed soon. The following link will work once it is approved.
http://www.concrete5.org/marketplace/addons/safe-html/...
ZillionProductions replied on at Permalink Reply
ZillionProductions
Sounds like a great solution, I'll give that a try as well. I'm sure many will appreciate your Add-on :) Thanks for thinking along!
JohntheFish replied on at Permalink Reply
JohntheFish
Package with the block template is now available.
ZillionProductions replied on at Permalink Reply
ZillionProductions
Cool, I'll check it out and give it a try ;) Thanks!