Announcement

Collapse
No announcement yet.

getting system environment variables

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

    getting system environment variables

    I posted in the 5.5 topic area and didn't get an answer. I'm hoping some of you coders and gurus here might help me. I need to know if/how I can access a system variable.

    on miva merchant 4.4 I could use openui to do an mvCall and get all the s. or e. types of variables. I could setup an environment variable inside of htaccess in apache. And call it from within Miva Merchant 4.4 using e.variablename

    How can I do this on Merchant 5.5?

    And will they still be e. or s. variables?

    How can I get the SetEnv value I set in htaccess from within storemorph?
    If storemorph can't do it natively, then can toolkit or toolbelt get it?

    #2
    Re: getting system environment variables

    Tool kit can do it. Just use the vassign and assign it to a global variable. Then you can &mvt it.

    <mvt:item name="toolkit" param="vassign|ip|remote_addr" />
    Your IP: &mvte:global:ip;
    Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
    Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
    Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
    Facebook http://www.facebook.com/EmporiumPlus
    Twitter http://twitter.com/emporiumplus

    Comment


      #3
      Re: getting system environment variables

      K

      I'm prety sure they wil become system variables.

      You can view ALL system variables using eigher of these commands from toolbelt.


      <mvt:item name="ry_toolbelt" param="varlist|system" />

      <mvt:item name="ry_toolbelt" param="eval|varlist('s', '', l.all_settings)" />
      Ray Yates
      "If I have seen further, it is by standing on the shoulders of giants."
      --- Sir Isaac Newton

      Comment


        #4
        Re: getting system environment variables

        Thanks guys, I'll try all three methods and see i they work.
        I didn't know if empressa was designed to only pass through certain ones.. or if it would grab them all. I'll see.

        Comment


          #5
          Re: getting system environment variables

          hmm.. apparently empressa doesn't pass through server environment variables unless it has already specificed them.

          In my htaccess, I have set a server var
          SetENV KELLY_FOO "kellyfoocontents"
          and just to make sure I also set
          PassENV KELLY_FOO

          and then I tested to make sure it was being set.
          I know it is becuase in an html page
          I can echo the contents of the variable
          <!--#echo var="KELLY_FOO" -->

          kellyfoocontents is output on the page just perfectly

          but it's just spit out as text. And that won't work from within miva merchant.
          I need to get it into a variable so I can do some mv:if things with it.

          I tried using ray yate's toolbelt to show all the system variable, using both methods suggested in this thread.

          KELLY_FOO doesn't show up in the system variables list.

          I tried what WCW suggested and got no output like so:

          <mvt:item name="toolkit" param="vassign|kf|KELLY_FOO" />
          Your kelly foo variable is: &mvte:global:kf;

          I'm guessing in pre miva merchant 4.x this would have been a e.xxxx kind of variable. but I don't think those exist anymore.

          anymore ideas on how to grab this server environment variable from within miva merchant?

          Comment


            #6
            Re: getting system environment variables

            Ok here's the long way around the barn. First #echo is a server side includes (SSI) directive.

            1. Save this <!--#echo var="KELLY_FOO" --> in a file kfoo.shtml

            2. Then in your page template use this
            <mvt:item name="ry_toolbelt" param="call_get|g.KELLY_FOO|'http://www.yoursite.com/kfoo.shtml'" />
            &mvt:global:KELLY_FOO;

            If you do this to in the head tag or global header it will be available for the entire store.

            I used the benchmark command from toolbelt to see how much impact it had on page load. Benchmark kfoo: Elapsed Time = 0.008013 sec.
            Ray Yates
            "If I have seen further, it is by standing on the shoulders of giants."
            --- Sir Isaac Newton

            Comment


              #7
              Re: getting system environment variables

              I will try that.

              I did figure out how in htaccess to set a cookie. Then I was able to load the cookie with toolbelt into a global variable and then use it.

              But this also doesn't work because the cookie has to be 'set' it isn't available for the first screen that is displayed in the visit. I can't get the cookie value until the second page load. And I need the info for the very first screen the user will see.

              so.. I will try the method you suggest.

              I'm apprehensive that I'll get an environment variable that is caused by the server instead of the visitor though.

              it's geoip info. I"ll have to just try and see.
              Last edited by kayakbabe; 02-19-10, 12:34 AM.

              Comment


                #8
                Re: getting system environment variables

                What are you trying to accomplish? I might be able to make a better suggestion if I had a better understanding.

                Why do you need to set the variable in the .htaccess file instead of the store?
                Ray Yates
                "If I have seen further, it is by standing on the shoulders of giants."
                --- Sir Isaac Newton

                Comment


                  #9
                  Re: getting system environment variables

                  Hi Ray,
                  I finally figured it out with some help from the Miva empressa guy when I was at the miva conference back in feburary. Basically I want to use an apache module that sets an environment variable when a site visitors hits the site. I wanted to access that variable from within miva merchant.

                  We figured out that the apache module must load from the apache httpd.conf and not from htaccess. That way empressa "knows" about the variable. When the empressa instance starts is will provide an s.foo variable to miva merchant. (the key was the httpd.conf and not .htaccess)

                  So I had to install the apache module first and then restart apache and empressa.

                  Your tool belt let me see all the system variables. Thanks!

                  Kelly

                  p.s. I'm trying out some stuff with geoip from maxmind to set currencies and languages. I just wanted to use storemorph code with two modules I already had (tool belt from you and the currency module I bought from viking coders), with the geop ip info from the mod_geoip. I already pay for the geoip data from maxmind. So knowing I already had all those components, I challenged myself to figure out how to use storemorph and maybe toolbelt or toolkit to setup language and currency for my visitors.

                  Basically what I'm checking for if the visitor already set the currency or language in miva, if they haven't and it's their first view of the store.. then I set the language and currency for them. I'm doing this in the global header. If the visitor changed the settings, I don't change them back.
                  geoip is pretty darn fast in the php setup and I could ahve gotten the locaiton data that way, but getting the geoip info is like lightening when it's setup as an apache module. That's important for higher traffic sites.

                  hope that explains!

                  Thanks for the viewing of the system variables within geoip

                  Comment


                    #10
                    Re: getting system environment variables

                    In your "spare time" you should do a quick post about geoip. I've seen several times others looking for a way to identify the country of origin. Your experience mght be very helpfull.
                    Ray Yates
                    "If I have seen further, it is by standing on the shoulders of giants."
                    --- Sir Isaac Newton

                    Comment


                      #11
                      Re: getting system environment variables

                      We use the geolite (free) version (where we can download the ip ranges to our own database). I'd be curious as well to see why you chose the apache module over the php api or geolite versions.

                      Comment


                        #12
                        Re: getting system environment variables

                        Still having problems with this.
                        I've got mod_geoip installed on my linux server.
                        I know it's working becuase I can it in phpinfo() and I can also write short scripts in php, and bash and see the contents of those variables like so:

                        echo $_SERVER["GEOIP_ADDR"]. '<BR><BR>';
                        echo $_SERVER["GEOIP_CONTINENT_CODE"] . '<BR><BR>';
                        echo $_SERVER["GEOIP_COUNTRY_CODE"]. '<BR><BR>';
                        echo $_SERVER["GEOIP_COUNTRY_NAME"]. '<BR><BR>';

                        I get valid data for those four variables.
                        But, I can't seem to get to them from within miva merchant.

                        I've tried both toolbelt like so:
                        s.GEOIP_ADDR : <mvt:item name="ry_toolbelt" param="eval|s.GEOIP_ADDR" /><BR>
                        s.GEOIP_CONTINENT_CODE: <mvt:item name="ry_toolbelt" param="eval|s.GEOIP_CONTINENT_CODE" /><BR>
                        s.GEOIP_COUNTRY_CODE : <mvt:item name="ry_toolbelt" param="eval|s.GEOIP_COUNTRY_CODE" /><BR>
                        s.GEOIP_COUNTRY_NAME : <mvt:item name="ry_toolbelt" param="eval|s.GEOIP_COUNTRY_NAME" /><BR>
                        <BR><BR><BR>
                        and also per wcw suggestion:<BR>
                        toolkit vassign GEOIP_COUNTRY_NAME : <mvt:item name="toolkit" param="vassign|geo|GEOIP_COUNTRY_NAME" />
                        &mvte:global:geo;<BR>
                        <BR><BR><BR>

                        I also can't see the variables listed in teh miva merchant system variables which I checked with both:
                        <mvt:item name="ry_toolbelt" param="varlist|system" />
                        and
                        <mvt:item name="ry_toolbelt" param="eval|varlist('s', '', l.all_settings)" />

                        I know there must be a way....
                        Last edited by kayakbabe; 04-19-10, 01:42 AM.

                        Comment


                          #13
                          Re: getting system environment variables

                          I would think the miva engine only creates certain system variables. Those would not be among them. You could use the callurl to run the php program.
                          Bill Weiland - Emporium Plus http://www.emporiumplus.com/store.mvc
                          Online Documentation http://www.emporiumplus.com/tk3/v3/doc.htm
                          Question http://www.emporiumplus.com/mivamodu...vc?Screen=SPTS
                          Facebook http://www.facebook.com/EmporiumPlus
                          Twitter http://twitter.com/emporiumplus

                          Comment


                            #14
                            Re: getting system environment variables

                            update...

                            I chose the apache module because it is faster than the phpapi or geolite.

                            I learned through this process that the miva engine passes along the system variables that apache has available at the time the miva engine starts.

                            I also learned something about apache. You can't make a new system environment variable in htaccess. That environment variable has to exist before you can set or change it within your htaccess.


                            So... to get a new system environment variable your server didn't have before.. you have to setup the environment variable in the configuration file for apache (http.conf) and restart apache to initialize the new variable. Once apache knows about it.. then so will the miva engine.

                            Just to test it, I made up a system environment variable called KE_testvar in my http.conf and restarted apache. I could get the value I set for KE_testvar within miva. And I can manipulate it in htaccess and miva would get the new value from htaccess. This whole thing frustrated me for a bit until Mark said, "I don't get why it isn't working. It looks right. After you restart apache all the env vars are available. I've done it twice over here and there isn't a bug."

                            I was thinking... What? Restart? Apache restart? DUH!
                            I killed and restarted apache immediately and wa-la.. there it was!
                            The httpd.conf only gets called one time.. when apache starts up.

                            That is why it's so much faster to put permanent rewrites into your .conf file.
                            It is called only one time versus at every single hit to your website.
                            Last edited by kayakbabe; 01-13-11, 11:58 PM.

                            Comment

                            Working...
                            X