Announcement

Collapse
No announcement yet.

Need help with mvt:do function

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

    #16
    Re: Need help with mvt:do function

    Well, of course Bruce is correct!

    Seriously, I think he is and it is really a related but slightly different topic too. I think there are two reasons. Security and convenience.

    Bruce described some security concerns, but my own idea is a question: why would you use php style insecure scripting when you can contain your wild oates (so to speak) and keep your ideas in a safe boundry. If your mivascripts are built outside the Miva "framework" you leave those scripts open like php would -- IMO.

    On the convenience topic, if you don't create your function in a Miva module then you may be needing to reinvent the wheel over and over. I've rarely wrote a useful independent mivascript where I didn't need or want to tap into the Miva API. Even the in uncompiled days. If I knew the function existed why rewrite it? The Miva API is easily accessed in a module where in an independent script I MUST (re)write the same function myself or throw in tons of overhead to access what is already available. Might not apply to you but the latter is problematic if the Miva server/store is different than a standard config.

    I'll stop, I could rant even more...

    Scott
    Need to offer Shipping Insurance?
    Interactive Design Solutions https://www.myids.net
    MivaMerchant Business Partner | Certified MivaMerchant Web Developer
    Competitive Rates, Custom Modules and Integrations, Store Integration
    AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
    My T-shirt Collection is mostly MivaCon T-shirts!!

    Comment


      #17
      Re: Need help with mvt:do function

      Hi Scott:
      This was a learning exercise for me, never having tackled mivascript I thought I'd try it. Learned a lot over the past few days. When I started this exercise, what I really wanted was to learn to create a module that I could add to a site, with a token that I could place in a template. Haven't been able to find anything yet that will help me with that.
      A major shortcoming of Miva and the only one I can think of, is a lack of serious education materials, both for the template code and especially for mivascript. Proprietary software isn't my thing, locks you in and I've attempted to avoid it all of my career. I guess you can't have everything!
      Anyway, I'm trying to fumble my way forward with Mivascript as I have with other languages over the past 47 years that I've been programming. That's why I'm known as Luce Kanon. ;)
      Thanks again for your assistance Scott!
      All the best, Larry
      Larry
      Luce Kanun Web Design
      www.facebook.com/wajake41
      www.plus.google.com/116415026668025242914/posts?hl=en


      Comment


        #18
        Re: Need help with mvt:do function

        Have you seen our new Module Training Series? This will show you how to build a module and use our module API:

        http://www.miva.com/videos/category/...veloper-series

        This should give you the tools you need to get started.
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment


          #19
          Re: Need help with mvt:do function

          Hi Brennan:
          Thanks for your response.
          That's what I've used to get to this point. I created a mivascript function, compiled it and executed it using the mvt:do command.
          What I'm hearing from the forum that this is not good practice or even allowed.

          Did I miss the part where I can create my function as a module that can be added to my site and then execute it with a token from my template? That was my original goal.

          When I attempt to upload my .mvc mvfunction module to my site, I get the following message: Runtime error in mm5/5.00/admin.mvc @ [0000000c:000000a8]: admin.mv: Line 952: MvDO: Unable to find function 'Module_Description' Failed call to ProcessFileUpload"
          This is the mivascript for the compiled module I'm attempting to install. (I kept it purposely ultra simple until I could actually get it running)
          <MvFUNCTION NAME = "getZone" PARAMETERS = "zoneZIP, zone var" >
          <MvASSIGN NAME = "g.zone" VALUE = "{ 'not found' }">
          <MvFUNCTIONRETURN VALUE = "xxx">
          </MvFUNCTION>

          After getting the .mvc path correct, thanks to Scott, It does execute when I run it using mvt:do.

          BTW. How great is the security risk if my function receives my variable by reference and returns the result of my function in that variable. My intent is to read a database, get the value of one of it's columns and return that value in the by reference variable. Nothing is to be displayed from the function itself. Really puzzled and unable to understand the security risk in this. Can you clarify?

          Many thanks for your help in the past and now, Larry
          Last edited by wajake41; 06-08-15, 03:52 PM.
          Larry
          Luce Kanun Web Design
          www.facebook.com/wajake41
          www.plus.google.com/116415026668025242914/posts?hl=en


          Comment


            #20
            Re: Need help with mvt:do function

            Brennan:
            I've found the Module API Reference Guide. Looks like this will answer most of my question about creating an API module.
            I'm getting dangerous now.
            Cheers, Larry
            Larry
            Luce Kanun Web Design
            www.facebook.com/wajake41
            www.plus.google.com/116415026668025242914/posts?hl=en


            Comment


              #21
              Re: Need help with mvt:do function

              Hi Larry,
              I can sympathize with your confusion, because I only recently stepped out of that fog and began to do useful things with MivaScript and Miva Merchant modules. As such, I thought I'd share a few things that helped me at the point where you seem to be.


              For starters, I'll agree with you that MivaScript resources are thin, especially when compared to other development languages and frameworks out there. However, mivascript.com does document all of the syntax and built-in functions, including examples. Also, there's a place in these forums specifically for MivaScript questions, which is helpful. On a related note, it's important to be aware of the distinction and between MivaScript and Miva Merchant, because that will help you know where to look when you have questions.


              Also, I completely understand why you were using mvt:do to run your script from the template code. Learning this stuff is a process, so it's fine to start by learning MivaScript and actually writing working scripts before diving into the abyss of Miva Merchant. Mvt:do provides an easy way to drop a script into your site and see how it works.


              Now, whether you should implement your script that way in a live store is another discussion. I think the others here are providing sound wisdom from years of Miva development experience when they say that it's better to write an actual Miva Merchant module. Modules have access to Miva's built-in functions and API features, and are cleaner and easier to manage long-term. What actual harm exists by NOT doing this would really depend on what your script does, but it's not hard once you see how modules actually work.


              If you've been through that video training series, then I assume you've already downloaded a copy of the LSK. That's a crucial resource that has really helped me. It contains a ton of modules that you can use as a reference. You'll also want to grab the API documentation. If you look at that while going through the modules in the LSK, you should be able to learn a lot.


              With those resources, you'll find that converting your existing script to a Miva Merchant module only requires a few extra functions. The first is the Module_Description function, which is where you assign all of the variables that tell Miva Merchant what your module is and what API features it uses. The error you cited, "Unable to find function 'Module_Description'", means that function doesn't exist in the file you uploaded. All modules also require three other functions: Module_Install_Store, Module_Upgrade_Store, and Module_Uninstall_Store. You may not need to specify anything within these functions for your module, but they still need to exist. You can find examples of this in any module within the LSK.


              You also mentioned that you want to execute your function from a token. That means you want your module to use the "component" feature. This requires a few other functions that Miva Merchant will call at different times on pages where your item is assigned (you'll create an item in your store after installing your module, then assign it to the pages where you want it to be available). The script you have already written will likely be inserted into the ComponentModule_Render_Start function (required for modules using the component feature), which is called wherever your item is placed in the template. In the LSK, you'll find a folder located at modules/component. Everything in there uses the component feature, and can be used as an example. Again, reference the API documentation, because many modules use more than one feature and the docs will help you see which functions are required for each.


              Of course, when you get too stuck, you can always post something here in the forums and usually get a pretty quick answer. I hope this points you in the right direction and helps you work through some of the confusion.




              Josh

              Comment


                #22
                Re: Need help with mvt:do function

                Hey Josh:
                Thanks for your response, very instructional, going to print it as a guideline to what I need to do and watch for.
                Right now I'm pouring thru the API reference guide and that together with what you've provided gives me hope that I can accomplish what I want to do.
                Thanks again so much, Larry
                Larry
                Luce Kanun Web Design
                www.facebook.com/wajake41
                www.plus.google.com/116415026668025242914/posts?hl=en


                Comment


                  #23
                  Re: Need help with mvt:do function

                  Originally posted by joshpappas View Post
                  All modules also require three other functions: Module_Install_Store, Module_Upgrade_Store, and Module_Uninstall_Store. You may not need to specify anything within these functions for your module, but they still need to exist. You can find examples of this in any module within the LSK.

                  Josh
                  Point of clarification: the 3 functions you reference are NOT required for any module, but are required for a module that implements the data_store feature. The only required function for ALL modules is Module_Description.

                  Each feature (e.g. component, util, payment, system etc.) has a few required functions for that feature.
                  Gordon Currie
                  Phosphor Media - "Your Success is our Business"

                  Improve Your Customer Service | Get MORE Customers | Edit Any Document Easily | Free Modules | Follow Us on Facebook
                  phosphormedia.com

                  Comment


                    #24
                    Re: Need help with mvt:do function

                    Larry,

                    The OBVIOUS security risk, because you are accessing the database, is that you providing the password to the database in what is essentially "clear text" (just written has HEXD). Now, you could probably come up with a clever way to obscure it, but why?
                    Bruce Golub
                    Phosphor Media - "Your Success is our Business"

                    Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                    phosphormedia.com

                    Comment


                      #25
                      Re: Need help with mvt:do function

                      Hey Bruce: You're right. I took a look at my .mvc file. It's all there. So that's what Miva calls compiled object code?.
                      I get your point!
                      Larry
                      Larry
                      Luce Kanun Web Design
                      www.facebook.com/wajake41
                      www.plus.google.com/116415026668025242914/posts?hl=en


                      Comment


                        #26
                        Re: Need help with mvt:do function

                        Originally posted by Gordon - Phosphor Media View Post
                        Point of clarification: the 3 functions you reference are NOT required for any module, but are required for a module that implements the data_store feature. The only required function for ALL modules is Module_Description.

                        Each feature (e.g. component, util, payment, system etc.) has a few required functions for that feature.
                        Oops, thanks for the catch and for keeping me honest!

                        Josh

                        Comment

                        Working...
                        X