Welcome Visitor, Please Login or Register Now Saturday, December 21, 2024 05:14 PM 
Forums Index > Mewsoft > Documentations > Gadgets API
New Topic   New Reply
Search for:
Author Message
mewsoft mewsoft's personal page
Administrator Team Member
Posts: 5381 Display member's posts
Joined: 12-21-24 05:14 PM
Location: knxoville, TN, USA
Member Offline
View Member's Profile Visit member's website Mewsoft Corporation Send private message ICQ Messenger: ICQ AIM Messenger: AIM YIM Messenger: Yahoo MSN Messenger: MSN
 
Back to top
Gadgets API Edit Delete Reply with quote Quote
First Post Posted on: 01-25-19 02:33 PM last post first post


Gadgets API



Begaining with Auctionawy 2012 version 15.00 a new API integration tools implemended.

The new version API includes Widgets, Gadgets, Embeded Perl code, new templates tags, new template parsing etc.


What are Gadgets
=============

Gadgets are Perl code modules that you can call direct form the templates or widgets to perform

some tasks on the database or dynamic data or process anything on the server inside the application

context then display the results in the templates.


Calling this gadgets from your templates or widgets like this:


[gadget::gadget_name(arg1="value1", arg2="value2",...)::]


or use the shortcut:


[g::gadget_name(arg1="value1", arg2="value2",...)::]


you can pass any number of arguments with their values to the gadgets like you call functions in most
programming languages.


Gadgets files
=========
Each gadget is one perl module file .pm in the gadgets folder in the main application directory structure.

The gadget file name must be the same name as the gadget plus the extension ".pm".

For example to create a gadget called "hello" then you must create the module file "hellp.pm" in the gadgets

folder. The gadget file must have a Perl function called the same name as the gadget name "hello" in this example

so the gadget file hello.pm should looke like this:


sub hello {

my (%args) =@_;

   #Your code goes here
   # the hash array %args contains all the arguments passsed from the call in the template or widgets

}

1;

You will find many gadgets files in the gadgets folder and there is a demo gadget called NewGadget as a template

for gadgets you can copy it and modify to what you need.


# call this gadget from your templates or widgets like this:
#
# [gadget::NewGadget(arg1="value1", arg2="value2",...)::]
#
#==========================================================
sub NewGadget {
my (%args) = @_;
   
    # your code goes here. your code will run within the program context and
    # all the program variables and database connections are available for you.
    # $dbh variable hold the current sql database connection.
    # %Global array holds all the program configuration and settings.
    # %Param array holds all the browser query and forms data.
    # %Cookies array holds current session cookies.
    # %Plugins array holds any output code for redering plugins.
    # URL variable:
    # $Global{BaseUrl}, $Global{ProgUrl}, $Global{AdminUrl}
    # Folders variable:
    # $Global{BaseDir}, $Global{ThemeDir}, $Global{LangDir}
    # see the module file Configuration.pm for more variables and settings
    # to load and translate a view or gadget:
    # $view = &getView("my-view-or-widget-file-name-without-extensioin");
    # do your stuff with the view
    # to print and render the view to the user screen:
    # print $view;
    # do not return your output, just print it and it will be caught and inserted
    # where you called the gadget in your views or widgets.
  

   $out = "";

    while (($k, $v) = each %args) {
        $out .= "$k = $v";
    }

   # return the gadget output, do not print to browser or stdout direct.

   return $out;

}#end sub
#==========================================================
1;


As you see, the gadget function must return all its output and do not print direct to the browser or to the STDOUT etc.

The gadget output is insert where the gadget tag inserted inside the template, therefor it has to return any output and not

to print direct to the output.

Please browse the gadgets folder for many default gadgets that comes with the products.

Thank you


Mewsoft Support
www.mewsoft.com

Page 1 of 1
Go to page:

New Topic   New Reply Mark Unread
Jump to:  
Delete   Move     Lock   +Favorits   +Notify   Print