We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

PHP in Verge3d Development

Home Forums General Questions PHP in Verge3d Development

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #21018
    Crunch
    Customer

    I would like to add some PHP to my user interface that mounts my verge app – more specifically i would to be able to test it locally in verge dev enviornment. Is there any way to configure Verge3d app manager to recognize and process PHP?

    #21025

    Hi,

    You can copy your Verge3D application folder (which contains only static files) to the PHP environment (Apache web server folder for static files?) and embed it in a web page with iframe. This way, your 3d app will be loaded in the context of the website, so Puzzles/JavaScript will have the access to any HTML elements provided by PHP. When working with 3d graphics, select the export path to update the gltf file in the PHP folder (no need in the App Manager after you created an app and copied it to a website folder.

    Chief 3D Verger | LinkedIn | Twitter

    #21029

    If you got WordPress, the easiest way to embed Verge3D app is to just use the plugin.

    Chief 3D Verger | LinkedIn | Twitter

    #21044
    Crunch
    Customer

    Thanks for the tips Yuri. What I ended up doing (so I can test locally) is I changed the configuration file in Xaamp to point to my document root being my Verge applications directory, instead of the default c:/xampp/htdocs folder

    Directions I found here: http://www.javadtaghia.com/clam/xampp-linux-windows/howtochangexampplocalhosttoanotherfolderoutsidexamppfolder

    I then add some PHP code instead my projectname.html file and rename it with a .php extension. For testing I have xampp running and chrome (via xampp) open pointed at the file I am working on, and have firefox (my default browser for verge3d app) open where I can experiment in puzzles. Then I just tab over to chrome and refresh to quickly view the results.

    Seems to be working great so far. The reason I had to get into PHP (and Mysql) in the first place is to be able to make content available only to registered users (via a login and registrations pages)

    I wish there was a puzzle and ‘easy’ button for that shit!

    My experiments so far show that trying to ‘envoke’ php code (even on via a local server) within puzzles isn’t going to work. I am I correct there?

    For now, the code (PHP + mySQL) I am using (more like tweaking as I am not smart enough to write it) to manage logins creates a few Session variables like username and user id. I’d like to be able to access those in puzzles so for example, when a user clicks a 3d cube object,I have some HTML based puzzles that conjure up a modal window that gives a personalized message like “Great job <username>!”

    To do that, I need to access the Session variables in puzzles.

    Is there an easy way to do this?

    So far what I have figured out, is that after the user logins I assign the Session variable value to a hidden html element, like this

    <?php echo “<input type=’hidden’ id=’username’ value='”.$_SESSION[‘username’].”‘/>”;?>

    Then in puzzles, I use the html get attribute puzzle to get the value of the element with id “username” and assign it to a new variable inside puzzles.

    Which works, but is there a better way of doing this? Like any way to capture Session variables via puzzles or custom javascript?
    Thanks

    #21047

    Hi,

    I think your approach with using a hidden element and HTML puzzles is already good.

    Alternatively, you can write your $_SESSION[‘username’] variable to a global JavaScript variable and access it with JavaScript. We did something like this in our WooCommerce integration module.

    Another way is to embed some JavaScript in your php page so that it directly calls a procedure puzzle using that $_SESSION[‘username’] variable as argument.

    Chief 3D Verger | LinkedIn | Twitter

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.