Announcement

Collapse
No announcement yet.

Can not get a custom global variable from the URL

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

  • Can not get a custom global variable from the URL

    I'm trying to pass my own variable in the URL, similar to what this video explains: https://docs.miva.com/videos/working...get-parameters

    But, no matter what I've tried, the value I'm passing doesn't seem to be automatically assigned to a global variable. I've tried using it in an expression with g.MyVariableName to display specific text if the variable value matches what I passed in the URL and I've tried just displaying the entity using &mvt:global:myvariablename; but nothing is displayed.

    Any input on where to start to looking to get this to work?

    Thanks!
    ----------------------
    Kelly

  • Well, yea...give us specifics of what code you are using. Are you passing in a form? A URL? If its in a form, what type of field are you using and method, etc., etc
    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


    • /something.html?colin=hungry

      &mvt:global:colin;

      will output "hungry"

      want an if/else?

      <mvt:if expr="g.colin EQ 'hungry'">
      eat chocolate
      <mvt:else>
      work!
      </mvt:if>
      Last edited by dreamingdigital; 02-28-20, 02:53 PM.
      Colin Puttick
      I solemnly swear that I am up to no good...

      Comment


      • Thanks Bruce & Colin. Originally, I was trying to get this to work on a custom page, but I've tested it on a couple of standard Miva pages (CTGY and ABUS) with the same results. It just does not register the global variable. Here's my test code on all pages.

        &mvt:global:myvariable;
        <mvt:if expr="g.MyVariable EQ 'MyValue'">
        Test
        <mvt:else>
        Test 2
        </mvt:if>

        Here's what I've appended to the URLs: ?MyVariable=MyValue

        I've tested the entity and the if statement with all lowercase and camel case like the URL in case it made a difference.

        We have multiple stores and I've tested in a couple of them as well as a developer store on mivamerchantdev.com. It works in the developer store, but not in our existing stores. Our stores have been around 15+ years and upgraded over time, but the developer store I just signed up for sometime in the last 6-12 months.

        In our existing stores, the entity either doesn't show at all or I get question mark icons like in the attached image and the if statement always returns "Test 2".

        Our stores and the developer store all have the same Merchant and MivaScript Engine versions and they are all on MySQL.
        Miva Merchant 9.14.00
        MivaScript Engine v5.33
        Database API: mysql
        ----------------------
        Kelly

        Comment


        • When stuff seems magically not working, I usually submit a support ticket: https://support.miva.com/supportsuit...Tickets/Submit
          Colin Puttick
          I solemnly swear that I am up to no good...

          Comment


          • hmm, that image makes me think it might be a character encoding issue, though that shouldn't effect CGI variables...

            try this

            &mvt:global:myvariable;
            <mvt:if expr="trim(g.MyVariable) EQ 'MyValue'">
            Test
            <mvt:else>
            Test 2
            </mvt:if>

            if that doesn't work, call support like colin suggested
            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

            Working...
            X

            This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

            This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.

            Accept