Announcement

Collapse
No announcement yet.

Variable values in SMT Code

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

    Variable values in SMT Code

    We used to be able to do things like this in mivascript:

    <MvASSIGN NAME="{'g.'$var}" VALUE="{value}">

    But that doesn't seem to work in SMT Code

    <mvt:assign name="'g.total_'$l.thisCoupon" value="l.settings:coupon:total" />
    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

    #2
    Re: Variable values in SMT Code

    I don't think it is currently supported in SMT
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: Variable values in SMT Code

      bummer...its one of my favs...sniff, sniff.
      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


        #4
        Re: Variable values in SMT Code

        Bruce, have you tried using an entity, something like:
        Code:
         <mvt:assign name="g.total_&thisCoupon;" value="l.settings:coupon:total" />
        Last edited by Kent Multer; 11-20-15, 10:06 AM.
        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


          #5
          Re: Variable values in SMT Code

          Originally posted by Kent Multer View Post
          Bruce, have you tried using an entity, something like:
          Code:
           <mvt:assign name="g.total_&thisCoupon;" value="l.settings:coupon:total" />
          No i haven't, does it work?

          Solved my problem by creating a helper function in a module. Which reminds me, if Burch or someone is listening...are we every going to have the ability to create and use functions in SMT code?
          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


            #6
            Re: Variable values in SMT Code

            No, sorry, I haven't tried that entity format myself.

            My own hunch about the SMT language is that Miva will eventually create an "expert mode" for templates, which lets you write them in straight Miva Script instead of SMT. We've all been moving in that direction, really, ever since they went to compiled code.
            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
              Re: Variable values in SMT Code

              Kent,

              Not to throw cold water on things, but that's unlikely to ever happen.
              Thanks,

              Rick Wilson
              CEO
              Miva, Inc.
              [email protected]
              https://www.miva.com

              Comment


                #8
                Re: Variable values in SMT Code

                From where I sit, you seem to have been moving in that direction for years. mvt:assign, mvt:do, mvt:call ... If the SMT language ever reaches the point where it's functionally equivalent to Miva Script, then I'll consider my prediction to be fulfilled, even without the Expert Mode setting. But at some point before that, the template compiler and script compiler will probably become so similar that maintaining them both will be redundant.

                Happy Friday!
                Last edited by Kent Multer; 11-20-15, 12:13 PM.
                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


                  #9
                  Re: Variable values in SMT Code

                  Fair enough, I can just say Dev didn't want to go as far as we've gone, so the likelihood is we'll stop soon.
                  Thanks,

                  Rick Wilson
                  CEO
                  Miva, Inc.
                  [email protected]
                  https://www.miva.com

                  Comment


                    #10
                    Re: Variable values in SMT Code

                    Bruce the helper function you mentioned is the only way your going to get that for now.

                    I've been doing this in Toolbelt for a long time.

                    <mvt:assign name="g.varname" value="'g.Inv' $ g.ndx" />
                    <mvt:item name="ry_toolbelt" param="assign|{ g.varname }|g.ShippingMethod" />
                    Ray Yates
                    "If I have seen further, it is by standing on the shoulders of giants."
                    --- Sir Isaac Newton

                    Comment


                      #11
                      Re: Variable values in SMT Code

                      Originally posted by Rick Wilson View Post
                      Fair enough, I can just say Dev didn't want to go as far as we've gone, so the likelihood is we'll stop soon.

                      Rick, I love the new SMT capabilities even though they compete directly with Toolbelt. I've always thought these should be part of the language. Following up on the original question:

                      While the following syntax shure would be convenient... <mvt:assign name="{ g.varname }" value="value expression" />
                      I think it would be simpler to add a helper function to MivaScript. e.g. miva_variable_assign()

                      <mvt:assign name="g.null" value="miva_variable_assign( g.varname expression, g.value_expression )" />

                      This would be be a great compliment to the existing function miva_variable_value( g.varname expression ).
                      Ray Yates
                      "If I have seen further, it is by standing on the shoulders of giants."
                      --- Sir Isaac Newton

                      Comment


                        #12
                        Re: Variable values in SMT Code

                        Yes, Ray, that's exactly what mivascript coders have been using <mvassign name="{ g.somevalue$'_someLiterial }"... have been using for years, and very handy at that.

                        On the topic of where template coding is going, is there any intention of giving us the ability to do CREATE functions in SMT? Otherwise, complex coding becomes a nightmare to maintain and duplicate.

                        I've been using the following hack which helps, but relies on globles, which is not good.

                        Create a Page called "_functions"

                        In that page, write your stored procedure, for example

                        <mvt:if expr="g.SayHi">
                        <b> Hello there &mvt:global:SayHi; </b>
                        </mvt:if>

                        You can call that function with template render

                        <mvt:assign name="g.SayHi" value="l.settings:customer:fname" />
                        <mvt:do name="l.result" file="g.Module_Feature_TUI_MGR" value="TemplateManager_Render_Page( '_functions' )" />

                        ...workable, but limited and you have to pass 'parameters' as globals which can be dangerous.
                        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


                          #13
                          Re: Variable values in SMT Code

                          Ray, have you seen this approach?
                          Code:
                          <MvIF EXPR="{ [g.Module_Feature_TUI_DB].Page_Load_Code('SomePageCode', l.page) }">
                          	<MvIF EXPR="{ [g.Module_Feature_TUI_DB].ManagedTemplate_Load_ID(l.page:templ_id, l.managedtemplate) }">
                          		<MvDO NAME="l.xx" FILE="{ g.Store_Template_Path $ l.managedtemplate:filename }"
                          		 VALUE="{ Template_Render(l.null, l.all_settings) }">
                          	</MvIF>
                          </MvIF>
                          It doesn't do the usual template-manager initialization, but it does let you pass an all_settings structure to the called template, so you don't need to use global variables. It's probably faster, too, so it'd be a better choice for small functions. -- not original to me, BTW. My thanks to whoever first showed me this trick :^) .
                          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


                            #14
                            Re: Variable values in SMT Code

                            Hi Kent.

                            Yes I've seen and have done something very similar. You just gave me an idea however!

                            In Toolbelt you can call screens but have to pass data around inside global variables (either by copy or by Toolbelts reference command).

                            But I could add another optional parameter, to avoid that extra step. So if the structure is passed by reference, changes made on that screen could be passed back to the calling page.

                            <mvt:item name="ry_toolbelt" param="screen|screen_code_expression| [g.capture_variable] | [l.all_settings:somedata] " />
                            Ray Yates
                            "If I have seen further, it is by standing on the shoulders of giants."
                            --- Sir Isaac Newton

                            Comment

                            Working...
                            X