<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <?php $id = $modx->resource->get('id'); ?> [[!message? &pageid=`$id`]] </body> </html>
This question has been answered by strooman. See the first response.
$id = $modx->resource->get('id'); echo $id;
You need to put your php into a snippet. For example create a snippet called message and inside place
$id = $modx->resource->get('id'); echo $id;
Now when you call [[message]] on a page you'll see that it echos out the value of the current resource that the snippet has executed on. Hopefully that helps? Sorry if I've misunderstood what you're trying to do.
<p>The current resource id is: [[*id]]</p>
[[pdoResources? &parents=`[[*id]]` &depth=`0` &tpl=`ListRowTpl` ]]
I assume you're trying to do something more complex than that
$stmt = $dbh->prepare("INSERT INTO messages (name, email, message, pageid)VALUES (:name, :email, :message, :pageid)"); $stmt->bindParam(':name', $name, PDO::PARAM_STR); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->bindParam(':message', $message, PDO::PARAM_STR); $stmt->bindParam(':pageid', $pageid, PDO::PARAM_STR); // set parameters and execute $name = $_POST["name"]; $email = $_POST["email"]; $message = $_POST["message"]; $pageid = $modx->resource->get('id'); $stmt->execute(); echo "<script type= 'text/javascript'>alert('Your Message is succesfully submitted.');</script>"; } $dbh = NULL;
$currentUrl = $modx->makeUrl($modx->documentIdentifier, "", "page=".$page, "full");
$currentUrl = $modx->makeUrl($modx->resource->get('id'), "", "page=".$page, "full");