Forum OpenACS Development: dotLRN development tips, tutoriasl quick guides????

Hi all,

I'm trying to develop a portlet for dotLRN to implement some new tools. The problem is that I only want to develop an easy application that take data from a form and put it in the data base. Another portlet show the data and made some operation on it. That's all.

I would like to do it as soon as possible, but the only way I could find is to study all the openacs kernel code and documentation. It's really big and there are items I will never use.

Is there some quick tutorial to develop dotLRN Portlets? I mean more advance Portlets. The HTML editor tool is not enough. It is static...

I found a lot of dotLRN user documentation, but I didn't find some developer documentation, only OpenACS documentation.

Thank you in advance.

Pietro.

Collapse
Posted by Nima Mazloumi on
<h3>Dynamic Portlets</h3>

WARNING: YOU NEED TO KNOW THAT THE BELOW SOLUTION CAN CAUSE GREAT DAMAGE. THIS IS ONLY A QUICK SOLUTION AND YOU NEED TO DO A LOT MORE TO ENSURE THAT NOONE EXCEPT THE SYSTEM ADMIN CAN MAKE USE OF THIS EXTENDED FUNCTIONALITY.

  1. You can take the static-portlet package for this purpose. My suggestion is though to create a new package called dynamic-portlet where only a system admin can create portlets.
  2. Now edit the following page static-portlet/www/static-portlet.tcl and add the following two lines at the end of the page:
    eval [template::adp_compile -string $content]
    set content ${__adp_output}
  3. Now when you add new content to the portlet you can use all ADP template tags and also tcl code. Just make sure that you don't use the %-tag for the tcl. Instead use the tcl-tag. A sample list for instance could look like this, where you first do your tcl stuff and then use them in your html page.
    < tcl >
    template::list::create -name persons -multirow persons -key item_id -elements {
                first_names {
                    label "First Names"
                }
                last_name {
                    label "Last Name"
                }
            }
    
        db_multirow persons select_persons {
            select * from persons where last_name = 'Mueller'
        }
    < /tcl >
    < listtemplate name="persons" >< /listtemplate >


    Here another example with forms:
    < tcl >
    ad_form -name my_form -form {
            {first_names:text(text) {value ""} {label "First Names"} {html { size 55 }} }
            {last_name:text(text) {value ""} {label "Lastname"} {html { size 55 }} }

    } -validate { {first_names {[string length $first_names] >= 2} "First names must be more than 2 characters" } } -new_data { #do something here } -edit_data { #do something here } -after_submit { ad_returnredirect "." ad_script_abort } < / tcl > < formtemplate id="my_form" >< / formtemplate >



    Make sure you remove the above spaces on the tcl, listtemplate and formtemplate tags to make the examples work.
Collapse
Posted by Nima Mazloumi on
The above solution allows you to include other pages as well and extend static portlets to integrate what ever you want.
Collapse
Posted by Pietro Zuco on
Thank you very much Nima!

I will try the code as soon as possible.
Wait the deedback 😉

Pietro.

Collapse
Posted by Nima Mazloumi on
Just added guide with all templates required to integrate a new package with dotLRN. See here.

Cheers

Collapse
Posted by Andrew Grumet on
Great work, Nima!
Collapse
Posted by Nima Mazloumi on

For completeness: You can use any adp template tags in dynamic portlets. I just randomly tried this and it works:

< include src="/packages/acs-api-browser/lib/search" query_string="test" >

I wonder if we could not get rid of all the dotlrn-* and *-portlet packages and instead extend the application package to use dynamic portlets via includes on the one hand and to extend dynamic portlet to support user and admin portlets.

What do you think? This would make dotLRN smaller put package specific pages pack to the application package (in the lib folder for instance) and we would have a single portlet package that does all the magic.

Any comments?