<![CDATA[ Get PHP Variable from ID - MODX Community Forums]]> https://forums.modx.com/thread/?thread=103352 <![CDATA[Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id?page=2#dis-post-556169
it's a simple question, but i cant find the right solution:

how i get the PHP-Variable from one resource in the other?

I try to get the value "X-Type" form resource "12" to resource "25"

MODx Resource ID "12":
[[!mySnippet? &type=`X-Type`]]


MODx Resource ID "25":
[[mySnippet]]


mySnippet:
<?php
return $type;


]]>
joe-petts Jan 05, 2018, 11:17 AM https://forums.modx.com/thread/103352/get-php-variable-form-id?page=2#dis-post-556169
<![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id?page=2#dis-post-559708 markh Jul 19, 2018, 11:05 AM https://forums.modx.com/thread/103352/get-php-variable-form-id?page=2#dis-post-559708 <![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id?page=2#dis-post-559694 website.]]> trjnx123 Jul 18, 2018, 11:05 PM https://forums.modx.com/thread/103352/get-php-variable-form-id?page=2#dis-post-559694 <![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559637 BobRay Jul 16, 2018, 08:33 PM https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559637 <![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559619 spam still a thing?]]> mrhaw Jul 16, 2018, 04:55 AM https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559619 <![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559110 You don't need to declare variables or their type before using them in PHP.
As a result, you have Variable Variables, so you may assign a variable to another variable.
for example,
<?php
$v='var1';
echo $v; // prints var1
$$v = 'var2';
echo $$v; // prints var2
echo $var1; // prints var2
?>]]>
christian357 Jun 16, 2018, 05:28 AM https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559110
<![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559082 nuan88 Jun 14, 2018, 03:16 PM https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559082 <![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559075 showbox Jun 14, 2018, 08:12 AM https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-559075 <![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-558078
In snippet 1:

$_SESSION['type'] = 'something';


In snippet 2:

$type = $_SESSION['type'];


This assumes that snippet 1 will always execute before snippet 2, and that no snippets on other pages will use the value of the session variable.]]>
BobRay Apr 17, 2018, 10:32 PM https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-558078
<![CDATA[Re: Get PHP Variable from ID]]> https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-558068 https://modx.com/extras/package/setplaceholders
https://github.com/oo12/setPlaceholders

website.com/page.html?myparameter=myvalue

[[!setPlaceholders? &ph=`myparameter == request.myparameter`]]


Use placeholder [[+myparameter]] in resource
or in code:

$value = $modx->getPlaceholder('myparameter');



]]>
mrhaw Apr 17, 2018, 04:59 PM https://forums.modx.com/thread/103352/get-php-variable-form-id#dis-post-558068