Announcement

Collapse
No announcement yet.

Learning How System System Extension / Utility Modules Operate

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Learning How System System Extension / Utility Modules Operate

    I have been dabbling in creating some basic modules for our store; I have gone with a System Extension to allow for simple Admin functions and database table queries for specific processes.

    I have been using the LSK for reference, I have a module installed which displays under the System Extensions section of admin.

    Let's say I have an input field here that displays for the admin and I wanted to update the value from that field to a specific table in the database when I hit the "Update" button. Where would the query to update the db table go in this scenario? Can the Module_System_Update MvFUNCTION see user-inputted data?

    I suppose I just do not know the order of operation for Empresa and how to best achieve this simple task.
    Benjamin Smith - Developer
    www.midwestgunworks.com

    #2
    You would define the tabs in Module_System_Tabs, define the form elements in Module_System_Content, and then use Module_System_Validate/Update to put the data into the database. Module_System_Validate should validate all input values or at the very least trim them. Then Module_System_Update would update the values. The data will be in global variables with the same name of the input elements. For example, if you had a textbox with the name "MyTest", you would access that value in Module_System_Validate/Update via g.MyTest
    David Carver
    Miva, Inc. | Software Developer

    Comment


      #3
      If you are using the module to update data, whether it's your own tables or miva merchant tables, you'll want to use the utility module features. The system module features are more for intercepting things that happen during normal store operation.

      Module_Utility_Content for your forms and UI in the admin part of your module

      Module_Utility_Validate to hold routines that check your input data to make sure it's valid before saving

      Module_Utility_Update to handle your data and other update routines - this is where you'd use the functions to update the record you refer to above.

      (and what Carver said above, although I do tend to use system module specifically for intercepting store related actions and utility features for "doing stuff" in the admin... just a personal choice.)
      M.A.D.* since 1997

      http://www.scotsscripts.com

      *miva application developers

      Comment


        #4
        Thank you David for the explaining how the global variable is create. This seems so simple and I had not came across this anywhere before. Also, I found out that having an input tag name with a '-' messes the variable up and just kept returning '0'. BUT naming the elements without a '-' fixes this :)

        I'll look into that Scot. Currently, the module will mainly display logs and stats with the exception of a couple admin-defined fields for exclusions. Is the difference between System Extension and Store Utility a "common-practice" thing or are more features avaliable with one over another?
        Benjamin Smith - Developer
        www.midwestgunworks.com

        Comment


          #5
          It's more common practice based on what the module is doing. System modules generally interact with the miva store system as a customer is shopping, while utility modules are for doing whatever you want in the admin side. That's how I look at it, but really, it's up to you. If you are going to make modules and sell them you may want to give thought to what feature set you want, but for what you're doing it doesn't matter.
          M.A.D.* since 1997

          http://www.scotsscripts.com

          *miva application developers

          Comment


            #6
            System Ex modules have three functions that are called when customers do things on the shopping pages, such as adding a product to their basket, logging in or out, etc. If you're writing a module that will only be active on the admin pages, then a utility module is generally the way to. But of course, you can write a system ex module where those three functions don't do anything; then it would, in effect, be equivalent to a utility.

            If you have a copy of the LSK, you can look at the modules in there for some examples of how to structure your module, what variable names to use, etc.

            Hope that helps ...
            Kent Multer
            Magic Metal Productions
            http://TheMagicM.com
            * Web developer/designer
            * E-commerce and Miva
            * Author, The Official Miva Web Scripting Book -- available on-line:
            http://www.amazon.com/exec/obidos/IS...icmetalproducA

            Comment


              #7
              Fortunately, I am early enough in my build where I can switch it to a Utility - so that is the route I decided. When it gets to production, I certainly do not want this module interacting on the clientside in any way, even if benign.

              Thanks for the help with this issue and THANK YOU for shedding light on how the form-submitted fields are set to global variables!
              Benjamin Smith - Developer
              www.midwestgunworks.com

              Comment

              Working...
              X