1
playsome
Hello all module devs what is your thoughts on keeping code and presentation elements seperate
  • 2012/1/6 19:39

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


I'm not much of a programmer, I consider myself to be more a front end developer I prefer HTML and CSS and the odd bit of javascript.

I also love xoops because I find it very easy to customise, easy to customise themes and templates. I can customise most templates to suit whichever site I am working on and it is usually pretty simple using the modules provided smarty variables to generate the content and editing the HTML and CSS to suit.

Where it becomes a tad trickier is when a modules php code is generating HTML elements. I have to try and hunt down which code is generating which elements and figure out how to edit that code so i can add a class or id or whatever without breaking the module.

I realise alot of module devs probably already keep all functionality of the module completely seperate from the presentation/template side, but some dont and personally I feel it makes it so much more difficult to customise things.

I feel one of xoops great strengths is it's customisability, if you know some HTML and css you can pretty much get things looking exactly how you want on a site wide basis.

So what are your thoughts on this, should all HTML elements only be inside templates or is there a need to sometimes generate elements inside PHP code?

2
Mamba
Re: Hello all module devs what is your thoughts on keeping code and presentation elements seperate
  • 2012/1/6 21:58

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Quote:
So what are your thoughts on this, should all HTML elements only be inside templates or is there a need to sometimes generate elements inside PHP code?

That's what Smarty and templates are basically for

My understanding is that Core developers will try to move all HTML code out of PHP files and into templates, creating a very clean Core. Maybe they can speak more to it...

I hope, developers of new modules will follow the same direction. And that there will be also developers who could help us with cleaning up the existing modules as well.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

3
Mamba
Re: Hello all module devs what is your thoughts on keeping code and presentation elements seperate
  • 2012/1/6 22:58

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


BTW - take a look at the modules being developed for XOOPS 2.6, like the Banners that is done by Mage.

It has a very nice separation of form, templates, and code.

I think, these modules will be a good example how we should program new XOOPS modules taking advantage of the XOOPS API.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

4
Peekay
Re: Hello all module devs what is your thoughts on keeping code and presentation elements seperate
  • 2012/1/7 0:41

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


If you are testing a conditional statement, is is not uncommon to pass some HTML directly to a template variable. Once it all works, you should really just output a value and format the HTML using IF/ELSE in Smarty.

However, if you are drunk and tired and it works perfectly as it is, you just go to bed.
A thread is for life. Not just for Christmas.

5
Mamba
Re: Hello all module devs what is your thoughts on keeping code and presentation elements seperate
  • 2012/1/7 1:08

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Quote:
However, if you are drunk and tired and it works perfectly as it is, you just go to bed.

That was a good one!
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

Login

Who's Online

400 user(s) are online (286 user(s) are browsing Support Forums)


Members: 0


Guests: 400


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits