1 (edited by paulcobb 2016-05-04 14:26:34)

Topic: Pass variable to baseUrl [SOLVED]

I need a pointer to get me sorted on this please.
I am creating a query string to pass the gallery name to a php page which houses the juicebox gallery.
Wihin the php page I am extracting the url
<?php
    // The value of the variable
    $Url = "photo-archive/" . $_GET["album"];
    echo $Url; // for testing
?>

I am now struggling on how to associate the $Url variable to baseUrl within the call for Juicebox?

<script language="JavaScript" type="text/javascript">
new juicebox({
baseUrl : *** how to define the variable ***,
containerId : "juicebox-container",
galleryWidth: "100%",
galleryHeight: "100%",
backgroundColor: "#222222",
showOpenButton: "false"
});
</script>
                <div id="juicebox-container">
                </div>
                <!--END JUICEBOX EMBED--></div>

Re: Pass variable to baseUrl [SOLVED]

The following should work (as long as the $Url variable has already been defined earlier in the page).

baseUrl: "<?php echo $Url; ?>",

You might also need to use the $Url variable in the path to the 'juicebox.js' file, e.g.:

<script src="<?php echo $Url; ?>/jbcore/juicebox.js"></script>

The code above assumes that your $Url variable does not end with a slash. You can adjust the code if necessary.

Re: Pass variable to baseUrl [SOLVED]

Brilliant - that has done the trick!
I had tried numerous combinations of what you propsed - but hadn't quite got it right.
Many thanks,

Re: Pass variable to baseUrl [SOLVED]

You're welcome!