Building a new module
- cyppher.nl
- Posts: 138
- Joined: Wed 19. May 2004, 18:38
- Location: Hilversum, Netherlands
Building a new module
cheers all,
Currently I'm preparing to build a new module for phpwcms. Basic concept is a custom product catalog which can output its data to an XML file for using in (custom) googlemaps infowindows.
As it's been a while since I've coded phpwcms modifications, I need some advice and best practices.
Couldn't find any recent info so here's my questions:
I've researched existing modules as the googlemaps plugin and the shopmodule. They all have backend.default, frontend.init, frontend.render and module.default php files and their core functions in the 'inc' folder.
What do I need to do (or reuse) to build the basic 'framework' for my new module, which functions and vars do I need no mather what?
I've tried but can't get my module to show up in the modules section in the backend. Am I right that enabling a module is no longer needed in 1.3.9? Phpwcms should now be able to detect modules itself, right? So how to enable a module in the backend?
Thanks in advance for all hints, I really like to document my findings and development to help others.
Cheers!
cyppher.
Currently I'm preparing to build a new module for phpwcms. Basic concept is a custom product catalog which can output its data to an XML file for using in (custom) googlemaps infowindows.
As it's been a while since I've coded phpwcms modifications, I need some advice and best practices.
Couldn't find any recent info so here's my questions:
I've researched existing modules as the googlemaps plugin and the shopmodule. They all have backend.default, frontend.init, frontend.render and module.default php files and their core functions in the 'inc' folder.
What do I need to do (or reuse) to build the basic 'framework' for my new module, which functions and vars do I need no mather what?
I've tried but can't get my module to show up in the modules section in the backend. Am I right that enabling a module is no longer needed in 1.3.9? Phpwcms should now be able to detect modules itself, right? So how to enable a module in the backend?
Thanks in advance for all hints, I really like to document my findings and development to help others.
Cheers!
cyppher.
How do you do? And how do you do your wife?
Re: Building a new module
Hi cyppher,
sounds good! Thanks! Great step! Appreciated!
Well, anyway it could be a good idea to contact the "headquarter" directly and to ask:
(A) whether a new mod is needed [generally] and
(B) for certain (actual) aspects of the dev state (while v1.3.9 is still devware ¡be aware¡)
I tell you, because only a few months ago some auspicious, promising new MODs
http://forum.phpwcms.org/viewtopic.php?f=8&t=17335
http://forum.phpwcms.org/viewtopic.php?f=8&t=17511
came up. After all, it took only weeks, but today ALL of them aren't developed further!
So, better ask the developer for detailed information...
sounds good! Thanks! Great step! Appreciated!
Well, anyway it could be a good idea to contact the "headquarter" directly and to ask:
(A) whether a new mod is needed [generally] and
(B) for certain (actual) aspects of the dev state (while v1.3.9 is still devware ¡be aware¡)
I tell you, because only a few months ago some auspicious, promising new MODs
http://forum.phpwcms.org/viewtopic.php?f=8&t=17335
http://forum.phpwcms.org/viewtopic.php?f=8&t=17511
came up. After all, it took only weeks, but today ALL of them aren't developed further!
So, better ask the developer for detailed information...
Last edited by Jensensen on Sat 8. Nov 2008, 01:44, edited 1 time in total.
- cyppher.nl
- Posts: 138
- Joined: Wed 19. May 2004, 18:38
- Location: Hilversum, Netherlands
Re: Building a new module
Hello Jensensen, thanks for your info.Jensensen wrote: Well, anyway it could be a good idea to contact the "headquarter" directly and to ask:
(A) weather a new mod is needed [generally] and
(B) for certain (actual) aspects of the dev state (while v1.3.9 is still devware ¡be aware¡)
So, better ask the developer for detailed information...
Well, as I see it, my client needs this kind of functionality (product catalog, no shop, just a catalog with a portable data container e.g. xml) so I need to build the 'enhancement'. My approach would be to build a module that other people might find usable too.
As for the dev release 1.3.9 (whatever buildno.), Oliver claims on phpwcms.de that 1.3.9 is stable and it's recommended not to use 1.3.3 anymore. So it seems to me that there should be no problems developing for 1.3.9 (Oliver, please confirm!).
I'll post my preparations tomorrow, basic descriptions of needed functionality.
Oliver, in the meantime, could you reply please? What should be the best approach in your eyes to develop a module?
Any other experiences (web-casa > googlemaps, exdata, jwimagerotator, shop etc) with building modules are welcome
Thanks for the support!
How do you do? And how do you do your wife?
- marcus@localhorst
- Posts: 815
- Joined: Fri 28. May 2004, 11:31
- Location: localhorst
- Contact:
Re: Building a new module
Hi,
I will try to share some of my experience.
1. take the files that come with mod_shop or mod_glossary - that's a good startpoint
it's good, to install both and look at the database, which tables are created! It's good at all, to study all files, to get an idea how it works.
the shop and glossary works different.
glossary got an own CP for rendering, shop use replacementtags.
2. duplicate, at example, the mod_shop folder and call it mod_yourmodulname (or however - you know)
3.to make your mod visible in Backend Modulsection and/or selectable as contentpart [1] follow this steps:
open module.default.php and edit the variables, it's explained in the file.
open lang/en.lang.php (depends on your BE language en should be default) and edit the first 2 vars
OK - did you designed your module tables yet? that would be good, if not - no problem.
open backend.default.php, this is the controlfile for all actions in MODULE section.
search for and comment it out.
why? it install the databasetables for your module, that you have created or need to create (study the files in setup folder to see what happen)
save all and open your Backend > MODULE
If all went well, your Module is selectable in BE Modulesection, right?
that was the easy part!
4. now it comes to your customization, and that's difficult to say how go further.
here some hints:
go to backend.default.php - the controller file - here you see, all $_GET actions are defined and on these actions some special file inclusions depending - means the different forms and display logics. that all is splitted in some other files found in the inc/ folder.
you will see some variables like $phpwcms['modules'][$module]
you should always work with basic things like print_r($GLOBALS); or print_r($phpwcms['modules'][$module]), to see which values are available (there is a special debugging function which format the code a bit, but I don't know the name right now)
best practice would be, to put all global variables for your module into $phpwcms['modules'][$module].
you can nearly reuse any function and variablescope given by phpwcms.
to write into your database you can use instead of writing all the php functions.
you will stumble about all this basic things in the given module files!
oliver commented all things, so it should be easy to understand.
5. it's no problem to develop for 1.3.9 ^^
6. study the phpwcms sourcefiles (I can't say this often enought ^^) - it takes a while to get an overview, but if you spend some time, many things will be easy to solve.
use a texteditor, which is able to search through your whole local phpwcms files, to find functions, function calls, variables etc.
ok, I hope this helps a bit to start. it's hard to explain all steps, how to build a new module, which function to use and so on.
it depends on your programming skills and how you read given scripts. as I said, you can reuse a lot of functions and logic from the phpwcms core code.
have fun, marcus
[1] you are able to set an own Contentpart with forms (Glossary Module), but you can use Replacementtags in CPs if you prefer (the shop works this way)
I will try to share some of my experience.
1. take the files that come with mod_shop or mod_glossary - that's a good startpoint
it's good, to install both and look at the database, which tables are created! It's good at all, to study all files, to get an idea how it works.
the shop and glossary works different.
glossary got an own CP for rendering, shop use replacementtags.
2. duplicate, at example, the mod_shop folder and call it mod_yourmodulname (or however - you know)
3.to make your mod visible in Backend Modulsection and/or selectable as contentpart [1] follow this steps:
open module.default.php and edit the variables, it's explained in the file.
open lang/en.lang.php (depends on your BE language en should be default) and edit the first 2 vars
Code: Select all
$BLM['backend_menu'] = 'Your Module';
$BLM['listing_title'] = 'Your Module';
open backend.default.php, this is the controlfile for all actions in MODULE section.
search for
Code: Select all
include_once($phpwcms['modules'][$module]['path'].'setup/setup.php');
why? it install the databasetables for your module, that you have created or need to create (study the files in setup folder to see what happen)
save all and open your Backend > MODULE
If all went well, your Module is selectable in BE Modulesection, right?
that was the easy part!
4. now it comes to your customization, and that's difficult to say how go further.
here some hints:
go to backend.default.php - the controller file - here you see, all $_GET actions are defined and on these actions some special file inclusions depending - means the different forms and display logics. that all is splitted in some other files found in the inc/ folder.
you will see some variables like $phpwcms['modules'][$module]
you should always work with basic things like print_r($GLOBALS); or print_r($phpwcms['modules'][$module]), to see which values are available (there is a special debugging function which format the code a bit, but I don't know the name right now)
best practice would be, to put all global variables for your module into $phpwcms['modules'][$module].
you can nearly reuse any function and variablescope given by phpwcms.
to write into your database you can use
Code: Select all
_dbQuery($sql, 'INSERT');
you will stumble about all this basic things in the given module files!
oliver commented all things, so it should be easy to understand.
5. it's no problem to develop for 1.3.9 ^^
6. study the phpwcms sourcefiles (I can't say this often enought ^^) - it takes a while to get an overview, but if you spend some time, many things will be easy to solve.
use a texteditor, which is able to search through your whole local phpwcms files, to find functions, function calls, variables etc.
ok, I hope this helps a bit to start. it's hard to explain all steps, how to build a new module, which function to use and so on.
it depends on your programming skills and how you read given scripts. as I said, you can reuse a lot of functions and logic from the phpwcms core code.
have fun, marcus
[1] you are able to set an own Contentpart with forms (Glossary Module), but you can use Replacementtags in CPs if you prefer (the shop works this way)
Re: Building a new module
Do you know ExData?cyppher.nl wrote:Basic concept is a custom product catalog which can output its data to an XML file for using in (custom) googlemaps infowindows
It's not equipped with XML and such stuff, but it has the googlemaps functionality included.
I adapted it once to something similar you might be working on.
http://www.volante.ch/index.php?referenzen
it's a catalog of buildings which can be sorted and filtered in various combinations and displayed in a listing with links to a detailed page for each entry, a imagelisting and the google map with all entries in it, each entry has a detailed info window with further content and the link back to the detailed page of the entry.
Maybe this could be useful to you.
The necessary changes to the original module are not dynamic, so it should be adapted to the specific needs.
PM me if interested.
Re: Building a new module
great explanation, marcus Thank you!
The exdata shown has a lot of googlemaps module integrated? I like that very much;)
The exdata shown has a lot of googlemaps module integrated? I like that very much;)
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
Re: Building a new module
In addition to marcus (or I didn't recognize)
Frontend Output of Modules are injected in a Var namend $content['all'] which is under the rendering control of phpwcms Templating.
Backend operations may work as normal PHP Files. (echo, (s)pprint...)
That is only marginal but helps a lot if knowing
Frontend Output of Modules are injected in a Var namend $content['all'] which is under the rendering control of phpwcms Templating.
Backend operations may work as normal PHP Files. (echo, (s)pprint...)
That is only marginal but helps a lot if knowing
Re: Building a new module
This time it really didn't take long until the newest attempt has already been cancelled. The last published MOD http://forum.phpwcms.org/viewtopic.php?p=110987#p110987 [confinement: the headquarter wasn't involved!]
was available online for two hours only.
was available online for two hours only.
Re: Building a new module
Jens,
this happens ! Sometimes Mods are withdrawn for security reasons
this happens ! Sometimes Mods are withdrawn for security reasons