[Tutorial] Improved [code] tags - Printable Version +- MyBB Community Forums (https://community.mybb.com) +-- Forum: Resources (https://community.mybb.com/forum-8.html) +--- Forum: MyCodes (https://community.mybb.com/forum-117.html) +--- Thread: [Tutorial] Improved [code] tags (/thread-213230.html) |
[Tutorial] Improved [code] tags - A Future Pilot - 2017-09-28 Hello everyone! I recently migrated my forum from SMF to MyBB, and I quickly discovered the default [ code ] tags are lacking some functionality. Here's a list of things I needed:
So, if you're in a similar boat as me, and need any or all of this functionality, here's what you do: 1. Allow [ code=Something ] tags where "Something" becomes the title of the code block
Replacement:
2. Preserve whitespace inside [ code ] tags
3. Don't add extra <br>s inside [ code ] tags If you've done #2, you'll see that #3 is a problem. The following info is taken from a post by metulburr (https://community.mybb.com/thread-205148-post-1249392.html#pid1249392) so thanks to him!! To fix this, we'll have to edit a core MyBB file, so be careful!
Now find the line:
and replace it with:
You're all done with #3 If you're not worried about #4, you can just save the file and re-upload it. Otherwise, continue on. 4. Don't convert tabs to spaces inside [ code ] tags For #4 you'll need to edit class_parser.php again. Find the lines:
And comment them out like so (note the double slashes at the beginning of each line):
You're now all done with #4. Just save class_parser.php and re-upload it. If you have any questions just let me know! RE: [Tutorial] Improved [code] tags - MonsteR_X - 2017-11-30 TFs...! RE: [Tutorial] Improved [code] tags - phorumws - 2022-04-23 NICCEE! I like this, and can use for one of my forums, but atm i'm editing a myBB forum and want the 'Code' text above the code box to say 'Links' and also the 'Code' button... CAN SUM1 PLS TELL ME WHICH FILE THE CODE (& QUOTE) BOX html/css IS IN SO I CAN EDIT THESE 'TITLES' PLS? Much Thanks P.S - Also need to change the size of text as atm its too large & bold, I want to remove bold & make italic for the code/quote boxes & make size of text size smaller! :-) RE: [Tutorial] Improved [code] tags - poeja - 2024-02-08 Hello, I find new problem here. When I post it while in "View Source" active, it will show custom title. Later on if I want to preview the post before posting it. The "Code Title" back to "Code" instead of [code=Custom Title] any fix for this? |