Announcement

Collapse
No announcement yet.

php and miva once again

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

    php and miva once again

    So on my pages external to miva I run a php script which populates a bunch of photos. All works well for the most part. Now, on my miva pages I run the same script using OpenUI "call" method to execute the script. The script executes but has no data. The problem is that the script makes a call to get a php cookie I previously set. When run inside Miva, the script for some reason doesn't see the cookie set via php. I know the php cookie is there on the Miva page because I can see it using my cookie viewing tool. So how does one pass a cookie to Miva that is to be used inside a php script? Any thoughts!!

    #2
    I don't think that will work. The CALL tag in Merchant is effectively activing as a web browser and returning the source of the page, but a cookie is not served as part of the page data, it's part of the http header data which would not be passed through to the real client computer. The same is true in the opposite direction; the CALL will not pass cookies to the PHP that the client computer has sent in to Merchant with the request.
    David Hubbard
    CIO
    Miva
    [email protected]
    http://www.miva.com

    Comment


      #3
      Originally posted by ILoveHostasaurus
      I don't think that will work. The CALL tag in Merchant is effectively activing as a web browser and returning the source of the page, but a cookie is not served as part of the page data, it's part of the http header data which would not be passed through to the real client computer. The same is true in the opposite direction; the CALL will not pass cookies to the PHP that the client computer has sent in to Merchant with the request.
      Thanks, do you think it would be possible to use javascript instead to retrieve the cookie rather than using a php call to retrieve the cookie? Or am I going to bump up against the same problem.

      It's pretty essential to what I'm trying to do and it requires the use of a php script (or other programming languages) to access a library for a web services api.

      Any suggestions or thoughts would be great. Would moving to Miva 5 help here?

      Comment


        #4
        I think you might need to make your content into an iframe so it has access to get and set cookies.
        David Hubbard
        CIO
        Miva
        [email protected]
        http://www.miva.com

        Comment


          #5
          not sure I follow you so bare with me. I have never used iframe. So I'll do some research. But basically what your saying is wrap the contents of my php script in an iframe tag and I should be able to get the headers information with cookies. So in my code within miva I have the php script run within a td tag. I should add a iframe tag around the php script which should allow me to get the header info. I will give it a try.

          Seems to me this is a big limitation of miva for people who want to wrap webservices into Miva. Is there an alternative solution or something better? Just trying to get some ideas. Thanks.

          Comment


            #6
            Yeah, an iframe is embedded in a document using a url just like regular frames. You can add variables to the iframe url though since merchant is always going to run and output its content first, including processing those variables. So you can specify the source of your iframe to be /include.php?var=%VAR{g.blah}% or whatever you need to pass to it, but it will have full interaction with the client computer because of it being a frame and the client doing the actual request.

            This limitation is the same for any template-based cart though, it's not unique to Merchant. For example, if you wanted to include a product page from Merchant in a PHP Nuke CMS system, you'd have to do something similar or the Merchant session id would never make it back to the client computer.
            David Hubbard
            CIO
            Miva
            [email protected]
            http://www.miva.com

            Comment


              #7
              What might be the issue is that you need to eval the call statement. Not sure how OpenUI's version is working but, when you use the Mivascript version, MvCall does nothing until you eval the "callvalue" which will contain the content of the called page. Just for grins, try evaling g.callvalue right after the %CALL() statement...otherwise, do what David suggests.
              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


                #8
                Hi bruce, not really familiar with openui so not sure what you mean by use eval. What code should I be using? Something like this:

                %CALL(script goes here)%
                %EVAL(g.callvalue)%

                Can you provide an example?

                Comment


                  #9
                  nope, just %VAR(g.callvalue)%...but its a long shot...reading the somewhat terse description, it appears that the %$CALL()% function should actually display the resulting callvalue...

                  but then again, reading David's response, I think he has his finger on the problem. Its not the Call function, its that your script is looking for a s.http_cookie value which isn't available just by using MvCall. You could try:

                  %ASSIGN(g.ThisPath|'ThePathToPHP?'$g.session_id)%
                  %CALL(g.ThisPath|GET)%

                  but I'm not sure if OpenUI will parse that syntax.
                  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


                    #10
                    Bruce, I tried this but OUI didn't seem to recognize the g.thisPath|Get in the %CALL%.

                    I'm at a lost, why couldn't I just call
                    %CALL(http://www.somedomain.myscript.php?username="somevalue")%

                    In this case I could populate the username with let's say a value from a javascript function(which gets the cookie I need) and have myscript parse the querystring rather than trying to have the script read a cookie.

                    Comment


                      #11
                      What function are you using to read the cookie in PHP? I have included PHP in my miva layouts before that read a cookie, but I had to use javascript to read the cookie.

                      Comment


                        #12
                        Originally posted by erichar11
                        Bruce, I tried this but OUI didn't seem to recognize the g.thisPath|Get in the %CALL%.

                        I'm at a lost, why couldn't I just call
                        %CALL(http://www.somedomain.myscript.php?username="somevalue")%

                        In this case I could populate the username with let's say a value from a javascript function(which gets the cookie I need) and have myscript parse the querystring rather than trying to have the script read a cookie.
                        Yes you could do it that way...what I was showing should have resulting in the same thing...OpenToken syntax is not heavily documented so some amount of trial and error is neccessary. g.thisPath should have contained the url plus the session id aurgument (essentially the cookie value).
                        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
                          Brandon, in php I'm doing the following on my script page

                          $username = $_COOKIE['MyCookie'];
                          This doesn't seem to work because of the reasons mentioned above. My thought would be to use Javascript within the php script to get the cookie. But I'm still not sure whether a php script run from Miva (via %call("myscript.php") will execute Javascript. I tried a couple of times but it didn't work.

                          Do you have a simple example of using javascript within a php script to get cookies?

                          Thanks

                          Comment


                            #14
                            unfortunately you can't use javascript "within" a PHP script. You can display the javascript on the page, but if you are hoping to use server side functions with the results from a javascript script on a page, I don't believe you can (or at least I have never done it). You are asking for a server side script (PHP) to work with data on the client side (JS). The JS values are dependent on the user and tbe browser, where the PHP values are determined before it can even send the request to the user.

                            My only suggestion is to try another PHP function: http_parse_cookie(), or try handling all cookie related data in Javascript.

                            I have used a %CALL(xx.php)% that has a javascript script that reads and displays cookie information.

                            Comment


                              #15
                              Originally posted by Brandon MUS
                              I have used a %CALL(xx.php)% that has a javascript script that reads and displays cookie information.

                              So, if you can forward the cookie data in an URL argument with the %CALL()% function, why not just use the miva scipt system variable s.http_cookie?
                              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