Home/ This Site / MovableType /Writing Template In Order To Improve Reading Code Friendly In MT

Writing Template In Order To Improve Reading Code Friendly In MT

When I built the blog system for Leafhhou, I found the page code is hard so that I can't reuse parts of code. It is bad smell. And it is hard to read the source code. For example, if you want to find the section of Copyright , the way is either using the find dialog, or reading more and more carefully. If you want to change it, you must change it on several pages. it is bitter.

To improve it, MT supports templates and widgets functions. I try to use this function when building the new web blog system. The result is below:

  • Templates are used friendly
  • If you use widgets as templates, please give up your ideas, because it does not make sense.
Finally, I have to introduce templates to my system.

OK, let me explain it.

Suppose that a Search form is used in several pages. To reuse it, the best way is to build a template, which includes the search part.

Where to create one template?
Just easy. Hover your mouse to "Design" , and a menu will pop up, click "Templates", you can create one here.

How to create?
Just copy the HTML code.

How to use template in the page?
Easy too. use the directive <$mt:include module="your_module_name" $> or <$MTInclude module="module name"$>.

That is all. easy? yes.

Seems I will have to spend much time improving the system.


See Also

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Creative Commons License
This weblog is licensed under a Creative Commons License.