Jump to content
  • 0

Passing PHP variable to DataPage URL


mgredmond

Question

I have a DataPage that I am embedding in  a Joomla article. I use Joomla ACLs, so I am not using Caspio's authentication. But I still want to get the user's Name and ID (from Joomla) to load into the Caspio database to track who created/updated the records.

I uses a PHP snippet of code to get the user's information and put it into a variable. This works because I can echo it to the screen.

I then want to pass the variable to the Caspio DataPage by modifying the embed code generated for the DataPage as follows:

As generated by  Caspio:

<script type="text/javascript" src="https://c1abs817.caspio.com/dp/ec1d70004e69797b8ed24ca4ade4/emb"></script>
<div class="cxkg"><a href="https://c1abs817.caspio.com/dp/ec1d70004e69797b8ed24ca4ade4">Click here</a> to load this Caspio <a href="http://www.caspio.com" target="_blank" title="Cloud Database">Cloud Database</a></div>
<div id="cbec1d70004e69797b8ed24ca4ade4"><a href="https://www.caspio.com" target="_blank">Cloud Database</a> by Caspio</div>

As modified by me:

<script type="text/javascript" src="https://c1abs817.caspio.com/dp/ec1d70004e69797b8ed24ca4ade4/emb?joomuser=<?php echo $username; ?>"></script>
<div class="cxkg"><a href="https://c1abs817.caspio.com/dp/ec1d70004e69797b8ed24ca4ade4?joomuser=<?php echo $username; ?>">Click here</a> to load this Caspio <a href="http://www.caspio.com" target="_blank" title="Cloud Database">Cloud Database</a></div>
<div id="cbec1d70004e69797b8ed24ca4ade4><a href="https://www.caspio.com" target="_blank">Cloud Database</a> by Caspio</div>

Notice that I have put my modification " ?joomuser=<?php echo $username; ?>" into the script in two places. Not really sure if it's needed in both places, but not knowing, I put it in both.

When I press the SUBMIT button on the DataPage, the record ( a transaction header record) is written to the database and then a details DataPage is loaded. The record is written as expected and the 2nd DataPage is presented, but when I check the record written, the user name from JOOMUSER is not recorded. 

Here is a screenshot of how I have the field set up on the datapage:

image.png.2547d757e2d2bffd010f63bf27cda1b2.png

Clearly, I am doing something wrong or missing a step. Any help would be greatly appreciated.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

I figured this out.

I was not quite accurate when I said I was loading the code into the Joomla article. The code was actually loaded into a custom module and the module was loaded into the article. There must be some failure in the interaction between the article and the module., because when I instead loaded the code directly into the article, everything worked as desired. 

Problem solved.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...