Sentora Support Forums
Adding views in modules - Printable Version

+- Sentora Support Forums (https://senforums.mach-hosting.com)
+-- Forum: General Forums - (Non-Sentora Support) (https://senforums.mach-hosting.com/forumdisplay.php?fid=1)
+--- Forum: Sentora Development (https://senforums.mach-hosting.com/forumdisplay.php?fid=54)
+--- Thread: Adding views in modules (/showthread.php?tid=2615)



Adding views in modules - Me.B - 02-20-2016

Currently the modules folders structure is:

- assets (for images/css/js).
- code ( for main module php core).
- hooks ( sentora daemon related code).

The common way of building html to concatenate html in the module currently.

Issue:

Changing the design is  complicated. 

Solution:
Adding a new folder:
- views

Where we store store views partials and load them using MUSTACHE:
https://github.com/bobthecow/mustache.php

The rendering would be like:
Code:
$m = new Mustache_Engine; echo $m->render(mytemplate, array('vars' => 'values!'));



We could also move later to handlebars, mustache views could easily used by JS too later as there is a mustache parser in JS:

http://mustache.github.io/
https://github.com/janl/mustache.js 

I plan already to add Mustche in /etc/lib as I will use it for Apache Admin module and vhosts building.

M B


RE: Adding views in modules - TGates - 02-22-2016

Hold off on this... I am not sure that is the way we want to go.
A redesign is already in the works.


RE: Adding views in modules - Me.B - 02-22-2016

what redesign?

This would help us obly mastering more modules rendering and get closer to a standard mvc.

I will try to show a module modified this way.


RE: Adding views in modules - jacobg830 - 02-24-2016

If we don't want to switch then extending ZPM to add views is possible and likely won't be too complicated. Compatibility could then be maintained with current modules (if desired).


RE: Adding views in modules - Me.B - 02-24-2016

(02-24-2016, 05:57 AM)jacobg830 Wrote: If we don't want to switch then extending ZPM to add views is possible and likely won't be too complicated. Compatibility could then be maintained with current modules (if desired).

adding views will not break the panel. It's more a convention. As will build html in /views/ and render them using mustache instead of building line .=. Can you easily modify such html trapped in variables?

On my side it was always a mess. This is why a lot of dev and frameworks got to MVC we are currently more MC dev.

M B