- CMS Made Simple Development Cookbook
- Samuel Goldstein
- 511字
- 2021-04-09 21:13:17
Will a Module solve my problem?
The previous two recipes have shown you how to assess two possible types of CMS extension, and to see if they are optimal for any specific problem. This recipe rounds out the analysis and shows you how to determine whether creating a Module is the most appropriate solution.
How to do it...
By examining your requirements, and comparing them to the strengths of the Module API, we can figure out whether or not a Module is the best way to implement your extension.
To do so, consult the following list, and determine if each item applies to the problem you are trying to solve. Feel free to write down a list of your answers (yes/no).
- Are you trying to solve a problem that requires multiple actions? An example of multiple actions would be both displaying a form and processing its results.
- Will you need to support localization and internationalization to solve your problem? For example, if your code will be displaying messages, will the messages need to be translated into multiple languages?
- Will your solution require an Administration panel?
- Will you want to share this solution with other people so they can install it into their own CMS Made Simple sites?
- Do you need to create new database tables or set up new preferences to solve your problem?
- Do you want your code to display help text in the Admin area, so site administrators understand what parameters are available and what the code does?
If you answered "yes" to any of the above questions, a Module is going to be the best way to implement your extension — with one possible exception. If you want to write an extension that you can apply to Smarty variables within a template to reformat their output (that is, a Smarty modifier), you will need to use a Tag. However, outside of that one case, a Module will be your best bet. If you answered "no" to all of the above questions, you could still use a module, but you might want to consider using a Tag or User-Defined Tag, as you will still be able to solve your problem with less complexity and overhead.
How it works...
A Module is PHP code that extends the CMSModule Class, which means that you start with a rich API that will save you a great deal of work. Module code can do virtually anything that PHP can do. The only thing that Modules cannot do (and which Tags can do) is act directly as Smarty modifiers.
Modules are extremely powerful and versatile, but that power comes with additional complexity. If you find that it would be possible to solve your problem with a Tag or User-Defined Tag, you should opt for the simpler approach. If, however, your requirements go beyond the capabilities of those extensions, there are very few limits to what you can accomplish with a Module!
See also
- Will a User-Defined Tag solve my problem recipe?
- Will a Tag solve my problem recipe?
- Create a "Hello World" module recipe
- TensorFlow與自然語言處理應用
- iPad+Procreate數字插畫設計案例教程(全彩微課版)
- IBM Rational ClearCase 7.0: Master the Tools That Monitor, Analyze, and Manage Software Configurations
- 使用AADL的模型基工程:SAE體系結構分析和設計語言入門
- Authorware應用案例教程
- 邊做邊學:Photoshop圖像制作案例教程(第2版·Photoshop 2020)
- 中文版Rhino 5.0完全自學教程(第3版)
- 剪映視頻后期剪輯零基礎入門到精通
- 中文版Photoshop 2020完全自學教程
- 有趣的Flutter:從0到1構建跨平臺App
- Maya 2020 超級學習手冊
- CorelDRAW X6平面設計與制作案例教程
- Instant Apache Sqoop
- 玩轉微信5.0
- CAXA CAD電子圖板和3D實體設計2021基礎入門一本通