The MyCode section allows you to create your own custom MyCode using regular expressions. This allows for additional formatting options when making a post. On the MyCode listing page, you can view the various MyCodes you have on your forum, along with a short description of their functionality. You can further manage the MyCode, as well as deactive/activate MyCode without having to edit the MyCode itself.
- Title
- A name for administrators to classify the MyCode by.
- Short Description
- A description for administrators that describes the function of the MyCode.
- Regular Expression
- A PHP regular expression that will search for a combination of characters. This must be valid - no validation is performed. (example: \[b\](.*?)\[/b\])
- Replacement
- The replacement for the regular expression above. (example: <strong>$1</strong>)
- Enabled
- Should this MyCode be available for use?
- Parse Order
- When should this MyCode be parsed in relation to other MyCode?
To create custom MyCode, you should fill out the title and description as described above. Then you need to make the "Regular Expression". To start, use the example \[b\](.*?)\[/b\]. In this regular expression, (.*?) represents the user's input between the tags. The tags, [b] and [/b], are what the user will use to designate the text to be modified.
Now that we have our regular expression, \[b\](.*?)\[/b\], it's time to create the replacement. The replacement is the HTML code that will replace the regular expression. In our case, the replacement HTML needed to create the proper formatting for the [b] [/b] tags would be <strong> and </strong>. "$1" is used to represent the text specified in the regular expression, remember "(.*?)"?. So our final replacement would be,<strong>$1</strong>. You can leave the rest of the settings as default.
Congratulations! You've just made your first MyCode. The [b] [/b] tags are already included in Mybb but hopefully you understand a little more about the creation of custom MyCode.
When both adding and editing a custom MyCode, you can test your regular expression and replacement without leaving or reloading the page, to ensure it works before saving.
- Test Value
- You should enter the MyCode that should be replaced along with anything else that should accompany it. For the example included above, you would enter: [b]Test text[/b]
Then, click on "Test MyCode," which will load the results without reloading the page. The results include:
- HTML Result
- The HTML returned as a result of your MyCode.
- Actual Result
- The text that will actually be displayed when the MyCode is used.
Home | Dashboard - Preferences - Version Check - MyBB Credits |
Configuration | Settings - Banning - Custom Profile Fields - Smilies - Word Filters - MyCode - Languages - Post Icons - Help Documents - Plugins - Attachment Types - Moderator Tools - Spiders/Bots - Calendars - Warning System - Thread Prefixes |
Forums & Posts | Forum Management - Forum Announcements - Moderation Queue - Attachments |
Users & Groups | Users - Groups - User Titles - Banning - Admin Permissions - Mass Mail - Group Promotions |
Templates & Style | Themes - Templates |