2015年3月18日 星期三

Flexi Custom Code Joomla module

Joomla is good for quick cms project but once the client needs special requirement, welcome to the hell~~. (Yeh actually I'm wandering at the hell now . . . . .)

Im working on a project, for some reason, most of data were not retrieve from K2 items table nor Joomla article table but few another custom tables.

in this case, obviously, non of modules in the world fit our needs.

ok~ in short, the problem is:
1. Our content were not from Joomla Article nor K2 Items (for some reason, dont ask me why)
2. We need to migrate the whole Joomla site's module/plugins to support our content table

The built-in Custom HTML module is a joke. it Just simply STATIC HTML and thats it.

Plugin can extend your joomla site in many ways but you have no way to decide where your plugin should display.

here you're few solutions:

  1. Modify existing extensions

    Since the data source is not related to K2 items nor Joomla article now, we are free to modify the existing module to migrate our custom table, or simply download any modules with cool effect and ignores if it supports K2 or not.

    This solution will fits 1 requirement. what if another one? I mean use the same layout with completely different source. Would u like to add N settings in the module xml file or duplicate the module?

    Also modifying an module will makes the module setting useless since we're no need to/unable to care about them. it makes your module chaos --- What if i need this module to display normal k2 items in future?

  2. Sub-templating the mod_k2_content

    K2 comes with a cool module k2 content.  This module have a complete settings to let you filter your k2 items in whatever you want. and the coolest setting of k2 content is sub-templating.

    it lets you create custom layout of K2 items in any way you like

    Sounds cool eh? yes it is IF OUR DATA SOURCE ARE FROM K2 ITEMS.

    with this solution, you will need to create tons of subtemplates and you will also need to create helpers for each template. And the same cons -- it will ignores all setting of the module because you dont need to use them.
  3. write your own

    it should be an ideal solution if time is not an issue.
so what im going to show you today is:
Flexi Custom Code I can say this is a robust version of built-in Custom HTML
This is a module to let you write your own html, php, js, css
It can use all Joomla classes such as JURI:base(), JFactory::getDBO()
You can even use exit() in this module
(the php include() function seems not work so well in this module)
the only setting of Flexi Custom Code is your source code. Feel free to write your own layout and feel free to call any fancy query and call from any other DB tables
Just think it as you write with plain php page~

沒有留言 :