MAXdev

Modules development - Is there some documentation or tutorial on module building?

JasonGW - June 24, 2005 - 03:28 AM
Post subject: Is there some documentation or tutorial on module building?
Because boy oh boy is the mod_template not really helpful for some of us development n00bs Smile It'd be very handy to have some idea what each of the files does and maybe a listing of usable parameters/hooks into the system.

Thanks!

Jason
PeteBest - June 24, 2005 - 03:30 AM
Post subject:
http://docs.maxdev.com/devdocs/

Aside from that get on Amazon.com and buy yourself a few php books
JasonGW - June 24, 2005 - 03:37 AM
Post subject:
Thanks, I will check out that site. I've got plenty of PHP books; php isn't my problem, it's just understanding all the complexity of a whole system such as this. I mean I love MD, used it since it first came out, but never really had the need to build a module before. Now I do Smile

Jason
PeteBest - June 24, 2005 - 03:46 AM
Post subject:
Once TiMax gets a bit more time he's going to be setting up a mailing list for 3rd party developers, so the MD-Pro devs can share their knowledge and help the community. At least, that's the theory Wink
JasonGW - June 24, 2005 - 05:14 AM
Post subject:
"In theory, Marge, Communism works. in theory."

(Little Simpsons Quote there) Smile
data_art - Aug 26, 2005 - 11:11 PM
Post subject: Jason, I'm with YOU.
Who knows how the hell this module API works? The functions are like manifestations of the spirit world - they seem to be there, but I can't directly influence them.
PeteBest - Aug 27, 2005 - 12:02 AM
Post subject:
If you let us know which function you're having trouble with we can assist. If you just have no clue how it all works you probably need more coding experience before attempting to create a module
data_art - Aug 27, 2005 - 03:26 AM
Post subject: Custom functions
Hey Pete

Sorry about the rant; you’re usually extremely helpful. Tell me, is there a way that I can circumvent using the Postnuke API altogether and just make my own functions? Whenever I create a simple function in the admin.php or user.php files, nothing ever shows up at all on my output.

For example:

function basic_function() {
echo “This is a basic function”;
} basic_function();

Nothing happens.
Duster - Aug 27, 2005 - 05:48 AM
Post subject:
Circumventing the API is not a good idea. Both PN and MD-Pro are moving towards all modules being API compliant. A programmer could probably tell you the advantages of a module being API compliant. I only know that it makes a diffference in sharing tables on multi-site installations.
data_art - Aug 27, 2005 - 06:06 AM
Post subject: Duster! Help me out here man...
Mastering the API might be a wise move in general. However, I'm getting zero output. For me, the API would be putting the cart before the horse.
PeteBest - Aug 27, 2005 - 07:48 AM
Post subject:
data_art: I think you're getting the API and pnHTML a bit mixed up. The API is just a set of commonly used functions, for example we have a function to clean up characters before they're submitted to the database etc etc. Nothing big or confusing about it really, each function is documented in our docs area that was linked to earlier. If you really wanted you could add your function into pnAPI.php in the includes directory, but if you're only using it once there is little point in doing that.

The code you used is valid and correct, the only thing that would make the output not show is if you've placed it in the wrong place within the module
dmiranda - Aug 27, 2005 - 10:20 AM
Post subject:
For PNHTML, try

in the first line of the funciton
$output = new pnHTML();

In the last line
return $output->GetOutput();}
data_art - Aug 30, 2005 - 11:11 PM
Post subject: Current Progress on the Module Template
In the module folder there are eight files:
index.html
pnadmin.php
pnadminapi.php
pninit.php
pntables.php
pnuser.php
pnuserapi.php
version.php

index.html is blank

pnadmin.php
This file appears to be the repository for the admin functions. (I speculate) Somewhere within this file is the code for getting the file to show up in the module named Modules as well as the code for displaying the corresponding icon in the administration icon grid. For certain, the admin code is in this file.

Along with my modifications up to this point, pnadmin is comprised of 896 lines. The first function one encounters is the "main" function. I have renamed it from whatever it was to "DougModule_admin_main". As a matter of fact, I did a search and replace of the generic module's name and replaced them all with DougModule. I renamed the generic module folder as well.

I created a user-defined function named NewbieFunction() and called it within DougModule_admin_main.

function NewbieFunction() {
$output =& new pnHTML();

// $output->SetOutputMode(_PNH_RETURNOUTPUT);

$output->SetInputMode(_PNH_VERBATIMINPUT);
// $output->TableStart(_TEMPLATE);
$output->Text("Gribbit");
$output->Text("Super Gribbit");
$output->Text("<html><table border=4 bgcolor=red><tr><td>Hello</td></tr></table></html>");
$output->SetInputMode(_PNH_PARSEINPUT);
// $output->TableEnd();

// $output->SetOutputMode(_PNH_KEEPOUTPUT);

return $output->GetOutput();
}

Nothing happened. By luck, I changed line 80/81 from

// Return the output that has been generated by this function
return $output->GetOutput();
// return NewbieFunction();

to

// Return the output that has been generated by this function
// return $output->GetOutput();
return NewbieFunction();

and then NewbieFunction() worked!

Of course, I'd rather not replace DougModule_admin_main() with NewbieFunction(). I would lose all of the functional razzle-dazzle.

My next goal is to get NewbieFunction to execute some functions instead of only outputting text.
data_art - Sep 10, 2005 - 02:12 AM
Post subject: Current Status of Module Development
Whew! There are 873 lines of code in admin.php. It took a few days to comment-out each line individually; now I will begin the task of uncommenting line by line in order to examine each function.

Sidenote: I tried to enlist the help of coders at Rentacoder.com. None of the developers there offered a bid to help. It seems that (at the moment) more coders are familiar with Postnuke coding...I'm sure MD-Pro will become more well known in time.
Lobos - Sep 10, 2005 - 04:28 PM
Post subject:
Hey in a few days I will be releasing an example module that will have you up and coding pnapi compliant modules in no time!

-Lobos
data_art - Sep 11, 2005 - 01:16 AM
Post subject: Thanks LOBOS!!
You have no idea how much I appreciate your offer. Is there anything I can do to help your progress? Maybe I could do some writing/editing. Instead, maybe I can ask el ama de casa to make some milk and cookies. Even *gasp* send money? Whatever you need to complete this tutorial – I would like to help.
Lobos - Sep 11, 2005 - 01:27 AM
Post subject:
Hey no worries - I don't need anything as my themes make me good money, every so often things go really well and I get a change to do some stuff for the community Smile
data_art - Sep 12, 2005 - 12:26 AM
Post subject:
[quote=data_art]Whew! There are 873 lines of code in admin.php. It took a few days to comment-out each line individually; now I will begin the task of uncommenting line by line in order to examine each function.

Sidenote: I tried to enlist the help of coders at Rentacoder.com. None of the developers there offered a bid to help. It seems that (at the moment) more coders are familiar with Postnuke coding...I'm sure MD-Pro will become more well known in time.[/quote]Hmm...looks like there's more than one admin function, covering different aspects of the administration. Where is the graphics file? It's really weird that I can't find the locations for the constants.
data_art - Sep 12, 2005 - 10:46 PM
Post subject: Current update
The function DougModule_admin_view() { } function seems to hold quite a bit of promise...
data_art - Sep 15, 2005 - 04:42 AM
Post subject: Hey Lobos...
...just wanted to offer you an encouring word for your efforts with the basic module tutorial. Any progress?
Lobos - Sep 16, 2005 - 01:24 AM
Post subject:
progress report:

Just completed a module generator - this is a ui to create a blank module - you can define the tables and columns, module name, etc and the module generator will write the files for you. The module will then install and be ready to devleop! This takes away that sucky task of having to get the module to install, creating the core files, etc

soon, maybe today, maybe tommorrow - but soon Smile
PeteBest - Sep 16, 2005 - 04:11 AM
Post subject:
Sounds interesting Lobos, I know of a module that used to do that, but it's a bit clunky to say the least, so it'll be interesting to see your version Very Happy
data_art - Sep 17, 2005 - 04:34 AM
Post subject: Developer's Mailing List
Is the developer's mailing list available? I'd love to participate.
data_art - Sep 17, 2005 - 05:01 AM
Post subject: Looking for a label definition...
Where is the definition for _PNH_PARSEINPUT? In the context of this question, it's a parameter of $output->SetInputMode(_PNH_PARSEINPUT) - a line within the mod_template_admin_main() function, inside of pnadmin.php.
Lobos - Sep 17, 2005 - 09:27 AM
Post subject:
Forget about all the boring pnHTML _PNH_PARSEINPUT type stuff and get your butt over to http://nvida.net and grab nvRender Smile

Enjoy Smile

PS: It's new so look out for bugs...
data_art - Sep 17, 2005 - 08:15 PM
Post subject: Thanks a bunch Lobos!
I installed it...now I just have to install Smarty Lite. Are your forums available? I tried to register, but haven't received my registration email.
Lobos - Sep 18, 2005 - 01:02 AM
Post subject:
why do you have to install smarty lite? Everything is contained in the module, you only need to install the module...

I just registered on the site and had no problems - check your spam Wink

-Lobos
data_art - Sep 18, 2005 - 04:38 AM
Post subject: Closer...but yet so far away
Next, I have to figure out how to get the items to load.
data_art - Sep 19, 2005 - 02:40 AM
Post subject:
Yippie! I've rediscovered the magic of echoing output: http://dougfranklin.com/index.php?module=DougModule&func=main
data_art - Sep 19, 2005 - 09:42 PM
Post subject:
Halfway there...

http://dougfranklin.com/index.php?modul ... &func=main
data_art - Sep 20, 2005 - 06:18 AM
Post subject:
Yes! I finally got the template module to work for me - now for the task of understanding it...

Although I'm quite familiar with the PHP Syntax I see in PHP books, the code in this module is far more Object-Oriented than what I normally see. It appears that all of the code displayed results from implementations of the pnHTML class.

So, at least two things are going on here: implementations of the pnHTML class are being used for the display of output, and the pnAPI is being used for database access/security/core MD-Pro functions. I don't see the places for custom uses of the API yet...still working on it.
Lobos - Sep 21, 2005 - 07:24 AM
Post subject:
Hey man, did you try that module I made? It uses html templating instead of pnHTML - have a play with it and you will soon understand what is going on...
dmiranda - Sep 21, 2005 - 07:39 AM
Post subject:
May be good to put a news in the frontpage.
Lobos - Sep 22, 2005 - 02:41 PM
Post subject:
Yes I did put the news as soon as I finished it, but it got lost - Max found it and posted though so it is there now.

-Lobos
dmiranda - Sep 22, 2005 - 04:00 PM
Post subject:
There now Smile
data_art - Sep 23, 2005 - 02:09 AM
Post subject: Lobos!
I'm running into a bit of trouble with your module:

http://dougfranklin.com/index.php?module=nvRender&func=main
PeteBest - Sep 23, 2005 - 04:16 AM
Post subject:
I don't think nvRender has any function for users. It's just a module generator and SmartyLite distribution, so only admin users need to be able to access it
data_art - Sep 23, 2005 - 04:22 AM
Post subject: Aahh...
Sad

I get the same result as an admin.
PeteBest - Sep 23, 2005 - 04:28 AM
Post subject:
Check to make sure you uploaded it correctly. From the error above it looks like it can't find or access modules/nvRender/pnlibrary/smarty_lite/class.template.php may be exactly the same problem file with the admin area as well then


I've tested it with MD-Pro 1.0.74 and not experienced any problems
data_art - Sep 24, 2005 - 02:10 AM
Post subject: Thanks LOBOS!!
This module now works. It's AWESOME. My mind is spinning as I contemplate the potential.
Lobos - Sep 25, 2005 - 03:08 AM
Post subject:
@data_art, Glad you like it - it was made special for people like you, ie those that can do some php, but haven't got the time to learn the intricacies of getting a module to install, etc, etc. Man it took me so much trial and error just to understand how pnAPI compliant modules work... be glad that you don't have to go through this process too LOL

@Pete, thanks for testing - I haven't had much feedback on the mod, so I am hoping it works as it is supposed to - have you encountered any problems, any suggestions on how it could be better? This goes for you as well, @data_art - feel free to make some suggestions!

-Lobos
data_art - Sep 27, 2005 - 02:18 AM
Post subject: PHP Classes
Lobos -

Do I apply my php classes to the template? For example:

class grid($rows, $cols) {

var $r = $rows;
$c = $cols;

function grid_function() {
// this is one of the grid functions
for($a; $a<($r+1); $a++) {
echo "<td>$a</td>";
}
}
return grid_function(return_value);
}
data_art - Sep 28, 2005 - 03:54 AM
Post subject: LOBOS! I'm SO CLOSE!!
pnuserapi.php:

I added this function:
for($a=1; $a<9; $a++) {
$amortization = array($a => array('month' => $a, 'calculation' =>'123-1234')));
}

However, only $amortization[8] shows up on the output. How do I get this for loop (the iterated contents of the $amortization array) to show up on the output?

http://dougfranklin.com/index.php?module=DougModule2&func=main
data_art - Oct 01, 2005 - 02:06 AM
Post subject: Lobos' Module that makes modules...
At first, I was skeptical. "Why would I want someone else's prefab module that doesn't necessarily do what I want?", I thought. Wow...was I wrong. This module is truly awesome.

Lobos, may I contribute to the documentation?
fabien - Oct 04, 2005 - 06:26 PM
Post subject:
Ok...
I'm nearly done with writting requirements so I have started to check on the technical part, that is to say MD-Pro module building.
To say it simply, for someone who does not come from the CMS world it is a bit hard.

What I understood is :
MD-Pro is a CMS. The goal of CMS is to build a common infrastructure to build on top of it in order to mainly share the same visual interface, share user database and other properties/behavior.
In order to do so people who want to build modules (additionnal CMS functionnalities) use functions from the API to properly interact with the "core", they can also use API functions for utility purpose.
In order to separate presentation from business logic the CMS use a template system. Templates embed business logic results inside of presentation code. Thanks to this layer the site can have a common presentation.


First question of course : Did I get it right ?
Then : What does the core really provide outside of user management ? (I didn't found any schema explaining that)
How to properly interact with the core ? (I think here also a nice schema with step by step interaction, like handshaking procedure, could REALLY help)
Why is there so many templating system out there ? Why don't we use XML/XSLT ? I mean regarding templating XSLT looks really powerful and adapted for me.
Is it a good idea to build the tables, business logic, etc... without thinking at all about MD-Pro then integrate this as a module later ? (if everything is done properly, meaning clean functions/class separation)


By the way I tried to play with Lobos nvRender module but I got this error :
Fatal error: TPL: [in line 0]: syntax error: file 'user_main.htm' does not exist in /hsphere/local/home/shanghai/shanghaiexpat.net/modules/nvRender/pnlibrary/smarty_lite/class.template.php on line 457
I checked my ftp log and every files are there. I installed the module and everything went smoothly.
I am trying to acess it through http://shanghaiexpat.net/admin.php?module=nvRender
I tryed to check the module docs but all I could found was Smarty-light docs.
Also, do I need to use Smarty-light to "enjoy" nvRender or could I use something else like Bender (I don't really know why I should use this template thing instead of this one but it looks like my boss prefer this one...).

Ok so I think I cover a bit of everything here. Please DO answer with RTFM if the answer is in there but just point me to the right direction (i.e. use a link).
I understand if it's crystal clear for you but for a newcomer I have to say it's a bit messy Silenced
PeteBest - Oct 04, 2005 - 07:15 PM
Post subject:
fabien wrote:
MD-Pro is a CMS. The goal of CMS is to build a common infrastructure to build on top of it in order to mainly share the same visual interface, share user database and other properties/behavior.


No. The goal of a CMS is to manage content (hence the name) anything else like that is merely a bonus

fabien wrote:
In order to separate presentation from business logic the CMS use a template system. Templates embed business logic results inside of presentation code. Thanks to this layer the site can have a common presentation.



Yep, it's much easier to work on if logic is seperate from design


fabien wrote:
How to properly interact with the core ? (I think here also a nice schema with step by step interaction, like handshaking procedure, could REALLY help)



Need to know what you're attempting to do before anyone can advise!


fabien wrote:
Why is there so many templating system out there ? Why don't we use XML/XSLT ? I mean regarding templating XSLT looks really powerful and adapted for me.



Because it's all opensource people can do things how they want, it's not as if we can stop people releasing templating systems! The reason we're not looking into XML is due the very poor rendering speed


fabien wrote:
Is it a good idea to build the tables, business logic, etc... without thinking at all about MD-Pro then integrate this as a module later ? (if everything is done properly, meaning clean functions/class separation)



It really is up to you, personally I'd say that sounds a very long winded way of doing it, everyone has their own preferences though, so what might work well for one coder might not for another


fabien wrote:
By the way I tried to play with Lobos nvRender module but I got this error :
Fatal error: TPL: [in line 0]: syntax error: file 'user_main.htm' does not exist in /hsphere/local/home/shanghai/shanghaiexpat.net/modules/nvRender/pnlibrary/smarty_lite/class.template.php on line 457



Same as the user above. The file user_main.htm doesn't exist as the module isn't available to users, so there isn't a user template. I've tested with MD-Pro 1.0.74 and several different php/mysql configurations and I haven't found any problems. If you have further problems please go to Lobo's site like he requested earlier
data_art - Oct 04, 2005 - 11:03 PM
Post subject: Lobos' nvRender works great!
There's two things:

(1) In the nvRender Admin section, when you name your module you want it to have ONE name. Instead of New Module, you'll want to use New_Module.

(2) You might want to reupload your files just to make absolutely sure they're all there.

Feel free to contact me.
Lobos - Oct 05, 2005 - 04:28 AM
Post subject: Re: Lobos' Module that makes modules...
data_art wrote:


Lobos, may I contribute to the documentation?


Yes of course! Just send to me and I will include it in the distro.

-Lobos
fabien - Oct 05, 2005 - 02:34 PM
Post subject:
Well few things regarding the nvRender :
does it make the use of Smarty_Light compulsatory after the module creation or is it just used for it's generation ?
(because I'd like to avoid the use of a template system and stick with strict CSS)
how to access it ? I mean I think I followed the standard procedure : upload files in modules/ , login as admin and init then start the module, try to access it but then I got the error I mentionned before. I double checked and the files are all there and the module name is nvrender, one word.


Also, do I need to care about autotheme when I write a module ? Not sure about this point. Is it possible to make the module "use" the global theme ? How ?


Do some of you use code generation tools ? (for building databases but also for basic data access/forms generations and class building)
If so which one do you recommand for PHP and of course that would fit nicelly with MD-Pro ?
fabien - Oct 06, 2005 - 02:43 PM
Post subject:
Is there a clean way to add properties to MD users or should we create a new "table" with the MD username then add our properties there ?
PeteBest - Oct 06, 2005 - 06:21 PM
Post subject:
fabien wrote:
Is there a clean way to add properties to MD users or should we create a new "table" with the MD username then add our properties there ?



Sorry, but I really don't understand what you want to do. I'm thinking you just want to look into the Dynamic Users section if you want to add a field to the users table. Please take some time to become familiar with the MD-Pro documentation, as if you did mean dynamic users you'd already know about it


Also, I'm quite mindful of this topic just being a general "how do I do this?" If you've got a question not relating to module building or documentation, please post in a new topic. Thanks
fabien - Oct 25, 2005 - 06:44 PM
Post subject:
I might be a bit dumb but ... MD-Pro API doc (several references to unwritten doc, especially security related) + MDG doc (really generic without giving steps and logic) is not enough for me, especially as the more important part are still "TBD"/"will write stuff about that there". For example security related things (what's the syntax for pnSecAuthAction, all those "::" things ? namespace ? domains ? I never read any of this in any documentation !) are quite important but I can't find a discussion about this ("Note: Add description of the security model. " in the official manual).
Hacking the template module does not really help too, it is really slow and painful. Worst it is very narrow and only help to do what it shows, it does not give the "big picture" and is not really professional.


For those who gone through this already (as Lobos testified "Man it took me so much trial and error just to understand how pnAPI compliant modules work") how have you done and what would you recommend ?
(module generator does help to start but does not help to understand)
PeteBest - Oct 25, 2005 - 06:59 PM
Post subject:
pnSecAuthAction is part of the permissions scheme, we have some documentation on permissions HERE and that subject has been covered in the forums thousands of times. Just do a search for permissions


As for the missing documentation, there are only so many hours in the day that we can contribute to MD-Pro. Writing documentation is a slow and painful process, to be honest we still have better documentation that some CMS packages twice our age. So basically it's getting done.


If you go to http://www.c0d3.de/html/ and do a search for the function you'll find the syntax, most of the API is unchanged from PN, so it should all be applicable
data_art - Oct 25, 2005 - 10:14 PM
Post subject: Fabien
Perhaps you're not looking at the documentation (or your perceived lack thereof) with the right perspective. You might see this as "a golden opportunity to get in on the ground floor of something big". In any event, I'm completely open to working with you or anyone who wants to make the documentation better. Contact me and we'll do our part to help to make it great.
fabien - Oct 27, 2005 - 09:13 PM
Post subject:
Ok Im getting thought it. Im sorry for being so asking but Im really not use to this kind of "large collaborative" environnement I would say.
Anyway I hope I will be able to write a tutorial soon about everything I understood about this whole MD-Pro/PN system.
Maybe we could start a wiki or something like that if some of you are interested in building a tutorial or something close ?
dmcl1 - Apr 06, 2006 - 04:17 AM
Post subject: Back to documentation
Hope it's appropriate to bring this matter up on an older, but I believe related, thread ... Now that you are moving documentation to the Wiki (that is a very recent change isn't it?), it is harder to find links to ALL of the developer documentation (API command reference, pnHTML class, etc.) unless you do a search of the forums. (Yeah, I know, always check the forums.)

Can I suggest that a link to http://docs.maxdev.com/devdocs/ be added to the Wiki's Developer Documentation page?
Duster - Apr 06, 2006 - 04:36 AM
Post subject:
When I moved the developer docs to the wiki section, I deliberately left behind the links to AP documentation, pnHTML, and modules development documentation. The reason is that those things are changing for 1.1 to some extent or other.
dmcl1 - Apr 06, 2006 - 04:48 AM
Post subject:
Understood. However, given that we have no definite date for the release of either MDLite or MDPro 1.1, isn't it still important for those documents to be readily available to the third party developer community? Or perhaps we are all just to sit on our hands and wait for the glorious release date? (tongue in cheek)

Seems it may be more helpful (at least in the sense of providing information for those looking "under the hood" of mods) for links to be temporarily included with a disclaimer as to the anticipated degree of changes and approximate timing. Yeah... timing ... I know, "when it's ready."

Just an observation from someone "returning to the fold".
Duster - Apr 09, 2006 - 03:16 PM
Post subject:
Done.
dmcl1 - May 04, 2006 - 01:39 AM
Post subject:
Okay, back to nvRender ... I feel very foolish asking this, but would someone please tell me how to access nvRender once I've initialized and activated it (i.e, what do I add in my Main menu)? Neither [nvRender] nor {nvRender} work.
dmcl1 - May 04, 2006 - 04:09 AM
Post subject:
index.php?module=nvRender&type=admin is what I was looking for, thanks.
All times are GMT + 13 Hours
Powered by MDForum 2.0.8 © 2003-2007 based on phpBB © 2001, 2002 phpBB Team
and by MDRebel which uses Theme Graphics by Daz
and by Attachment-Mod 2.4.3