TYPO3 Custom Tag Extension - necessary PageTS-Config for RTE and TypoScript Setup for lib.parseFunc*-Objects


/ Published in: TYPO3
Save to your folder(s)

If you want to code your own custom tag extension and package it as an TYPO3 plugin, there could be some issues getting things to work in RTE enabled textarea fields. The Extension Kickstarter only supports to add the necessary TypoScript setup for the tt_content.bodytext field but no configuration for proper redisplaying of the tag in RTEs is made.

With this setup (PageTS-Config and TypoScript Setup) you will be able to redisplay the tag in the RTE and also render it nicely with your plugin code.

Just create an extension with the Kickstarter, insert YOURTAGtag as extension key and replace YOURTAG with the tag name you like (also in the extension key).

Note: the PageTS-Config is non-destructive concerning already existing configurations, just insert it after your (propably customized) RTE configuration in the TSConfig field on your rootpage. Only settings I've found out to be necessary were added. Leave me a comment if something is redundant or unnecessary. Thanks!


Copy this code and paste it in your HTML
  1. # the following Page-TSConfig should be added:
  2.  
  3. # RTE button settings: allow User plugin
  4. RTE.default.showButtons := addToList(user)
  5. RTE.default.hideButtons := removeFromList(user)
  6.  
  7. # allowed/denied tags
  8. RTE.default.proc.allowTags := addToList(YOURTAG)
  9. RTE.default.proc.denyTags := removeFromList(YOURTAG)
  10.  
  11. # HTMLparser_rte settings
  12. RTE.default.proc.HTMLparser_rte = 1
  13. # don't mask special html characters like < or >
  14. RTE.default.proc.HTMLparser_rte.htmlSpecialChars = 0
  15. # protect specific, user defined tags
  16. RTE.default.proc.HTMLparser_rte.tags.YOURTAG.protect = 1
  17.  
  18. # entryHTMLparser_db settings
  19. # special html characters like < or > will be stored unmasked (get masked by re-display in RTE)
  20. RTE.default.proc.entryHTMLparser_db.htmlSpecialChars = -1
  21. # protect specific tag
  22. RTE.default.proc.entryHTMLparser_db.tags.YOURTAG.protect = 1
  23. # protect non matching tags
  24. RTE.default.proc.entryHTMLparser_db.keepNonMatchedTags = protect
  25.  
  26. # exitHTMLparser_db settings
  27. RTE.default.proc.exitHTMLparser_db = 1
  28. # protected non matched tags during fetching from database
  29. RTE.default.proc.exitHTMLparser_db.keepNonMatchedTags = 1
  30. # don't mask html characters like < or >
  31. RTE.default.proc.exitHTMLparser_db.htmlSpecialChars = 0
  32.  
  33. # RTE plugin "user" settings
  34. # define group name
  35. RTE.default.userElements.10 = My Own Tags
  36. # tag configuration
  37. RTE.default.userElements.10.1 = My First Tag
  38. RTE.default.userElements.10.1.description = The selected field gets wrapped with <YOURTAG>|</YOURTAG>
  39. RTE.default.userElements.10.1.mode = wrap
  40. RTE.default.userElements.10.1.content = <YOURTAG>|</YOURTAG>
  41.  
  42. # furthermore, we also need the following declaration in lib.parseFunc* objects in a template records setup field:
  43.  
  44. # common parsed elements (e.g.header fields)
  45. lib.parseFunc.allowTags := addToList(YOURTAG)
  46. lib.parseFunc.tags.YOURTAG = < plugin.tx_YOURTAGtag_pi1
  47. lib.parseFunc.nonTypoTagStdWrap.HTMLparser.tags.YOURTAG = < plugin.tx_YOURTAGtag_pi1
  48.  
  49. # add custom tag to parse function of the RTE
  50. lib.parseFunc_RTE.allowTags := addToList(YOURTAG)
  51. lib.parseFunc_RTE.tags.YOURTAG = < plugin.tx_YOURTAGtag_pi1
  52. # this line enables the "passthrough" of non-typo-tags to the HTML parser
  53. # you can also specify an cObject directly, without the need of a plugin call
  54. lib.parseFunc_RTE.nonTypoTagStdWrap.HTMLparser.tags.YOURTAG = < plugin.tx_YOURTAGtag_pi

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.