A field for displaying code
Permalink Browser Info Environment
Hi,
for a client i would need a field to enable users to enter code snippets (PHP, HTML and CSS) that don't get parsed of course, just for being displayed as clean text.
Would it be possible to add such a field to Block Designer?
Thank you,
Michael
for a client i would need a field to enable users to enter code snippets (PHP, HTML and CSS) that don't get parsed of course, just for being displayed as clean text.
Would it be possible to add such a field to Block Designer?
Thank you,
Michael
Type: | Discussion |
---|---|
Status: | Resolved |
Hi Ramon,
first of all, thank you for your speedy reply! :)
The problem is, that a simple text area does not prevent PHP code input from getting parsed. I created a simple block with just one text area field and then tried to put in a PHP code snippet - the output result was not clean text with all characters, but just some fragments of the original code. The rest, i assume, has been interpreted as executable PHP code and therefore not displayed.
Unfortunately none of the developers of related Add-Ons currently existing for Conrete5.6, namely "Highlighted Code Block" and "All in one syntax highlighter", seem to have plans to port their useful Add-Ons to Concrete5.7. At least Remo doesn't, as i have contacted him just recently, even willing to pay for porting his Add-On.
I can pretty much live without code highlighting, if there only was a way to present code as plain text. Redactor's preformatting feature is buggy and messing up the code as soon as the block is edited again, so it's unusable at the current state.
Do you think, you could (and would like to) create a "code" field as suggested, where tags and code related characters are correctly transformed into HTML entities?
Kind regards,
Michael
first of all, thank you for your speedy reply! :)
The problem is, that a simple text area does not prevent PHP code input from getting parsed. I created a simple block with just one text area field and then tried to put in a PHP code snippet - the output result was not clean text with all characters, but just some fragments of the original code. The rest, i assume, has been interpreted as executable PHP code and therefore not displayed.
Unfortunately none of the developers of related Add-Ons currently existing for Conrete5.6, namely "Highlighted Code Block" and "All in one syntax highlighter", seem to have plans to port their useful Add-Ons to Concrete5.7. At least Remo doesn't, as i have contacted him just recently, even willing to pay for porting his Add-On.
I can pretty much live without code highlighting, if there only was a way to present code as plain text. Redactor's preformatting feature is buggy and messing up the code as soon as the block is edited again, so it's unusable at the current state.
Do you think, you could (and would like to) create a "code" field as suggested, where tags and code related characters are correctly transformed into HTML entities?
Kind regards,
Michael
Hi Michael,
Ah yes of course, it's being parsed! Long day already...
Uhm, yeah I certainly could do that. That won't be in the next 24 hours, but I will see what I can do for you this week (perhaps somewhere in the weekend). Quite loaded with other projects, so have minimum spare time in my agenda! So if you could wait for a couple of days, I will do my best to get it done ASAP! Wished a day had 48 hours haha.
Kind regards,
Ramon
Ah yes of course, it's being parsed! Long day already...
Uhm, yeah I certainly could do that. That won't be in the next 24 hours, but I will see what I can do for you this week (perhaps somewhere in the weekend). Quite loaded with other projects, so have minimum spare time in my agenda! So if you could wait for a couple of days, I will do my best to get it done ASAP! Wished a day had 48 hours haha.
Kind regards,
Ramon
Ramon, you just rock!
And i totally agree with you, time has become the most precious thing in our times! It's crazy. It's not even the energy that's lacking, it's simply the amount of time for doing thing that's lacking each and every day... Of course i will happily wait for any solution you provide. Thank you so much for your kind support!
Cheers,
Michael
And i totally agree with you, time has become the most precious thing in our times! It's crazy. It's not even the energy that's lacking, it's simply the amount of time for doing thing that's lacking each and every day... Of course i will happily wait for any solution you provide. Thank you so much for your kind support!
Cheers,
Michael
Hi Michael,
Sorry for the delay in the completion of this. I've been too busy to get even started on my add-on projects. Whenever I get the change to get back to these again, I will start with this "code" field type. Sorry if you needed it in the meanwhile...
Kind regards,
Ramon
Sorry for the delay in the completion of this. I've been too busy to get even started on my add-on projects. Whenever I get the change to get back to these again, I will start with this "code" field type. Sorry if you needed it in the meanwhile...
Kind regards,
Ramon
Hi Ramon,
whenever you find the time to build that extension, I'm very much looking forward to it! Thank you!
Kind regards,
Michael
whenever you find the time to build that extension, I'm very much looking forward to it! Thank you!
Kind regards,
Michael
Hi Michael,
Here a first version of the code field type. Not sure if you need more functionality, but let me know. I made it the way I interpreted your request, hope it's how you wanted and otherwise just let me know.
Drop the "code" folder into packages/block_designer/field_types. And done! I will be updating block designer anytime soon, first want to have this field type exactly how you want it to be :)
Kind regards,
Ramon
Here a first version of the code field type. Not sure if you need more functionality, but let me know. I made it the way I interpreted your request, hope it's how you wanted and otherwise just let me know.
Drop the "code" folder into packages/block_designer/field_types. And done! I will be updating block designer anytime soon, first want to have this field type exactly how you want it to be :)
Kind regards,
Ramon
Hi Ramon,
thank you so much for your work, this is exactly what i'm currently badly needing!
This nice field type displays code with all tags and tabs and characters without modifying them in any way, and, above all, keeps it from being rendered!
What could i ask for more! Well, to be honest... of course there are advanced features, which would be very much appreciated, such as line numbers and code highlighting... but maybe it would make more sense for you to build that a separate payed Add-On...
Thank you again for this great christmas present!
Kind regards,
Michael
thank you so much for your work, this is exactly what i'm currently badly needing!
This nice field type displays code with all tags and tabs and characters without modifying them in any way, and, above all, keeps it from being rendered!
What could i ask for more! Well, to be honest... of course there are advanced features, which would be very much appreciated, such as line numbers and code highlighting... but maybe it would make more sense for you to build that a separate payed Add-On...
Thank you again for this great christmas present!
Kind regards,
Michael
Hi Michael,
Glad this is what you were looking for :)
As for code highlighting, I've thought about highlightjs.org. But that's client sided. Not sure if that's the best way to go though, as we could also do server sided. Things is if you have multiple blocks with code, you have to watch that you don't load the JS and CSS multiple times.. But well, we still can do highlighting in a next version, right?
If you have any suggestions about a highlighter, just let me know. I haven't had much time to dig deep into all this unfortunately.
Kind regards,
Ramon
Glad this is what you were looking for :)
As for code highlighting, I've thought about highlightjs.org. But that's client sided. Not sure if that's the best way to go though, as we could also do server sided. Things is if you have multiple blocks with code, you have to watch that you don't load the JS and CSS multiple times.. But well, we still can do highlighting in a next version, right?
If you have any suggestions about a highlighter, just let me know. I haven't had much time to dig deep into all this unfortunately.
Kind regards,
Ramon
First of all, thanks for your interest in block designer.
About your question, would that be just a simple textarea field with no editing afterwards. So input = output? Or you need more modification than this, like an editor of some sorts? Also, you want to make a difference between coding language, or throw all this in one field?
Not knowing the answers above, I do think it's possible. We already have a simple textarea field type and a WYSIWYG field type so... why not a "code" field type with some slicker options as well? :)
Let me know what your thoughts are about this!
Kind regards,
Ramon