hi, how can i create a php file? i created a php content type, and then created a document resource of type php. Instead of executing and returning html to my browser, it just download to my computer. Tried with a Static Resource, same result.
or, how can i upload a php file? it’s disallowed.
or, how can i pass a url argument/parameter to a php snippet in a html document from the url line?
thanks!
jealousy<>love
All PHP code in MODX has to be in a snippet or plugin. It makes the site much more secure.
Just create a snippet called MySnippet, put the PHP code in it, and put this tag on the page:
The code will execute when the page is visited.
-
☆ A M B ☆
- 24,524 Posts
MODx uses a templating system to manage all dynamic content. PHP code is handled via snippets (tags in the HTML), plugins (code that interrupts normal processing to override core functioning) or TVs using @EVAL binding.
In Evo, snippet code is passed through the PHP eval() function, with snippet parameters loaded into the GLOBAL array. In Revo, snippet code is written to file then included. Not sure how Revo handles snippet parameters.
Since the HTML is loaded from the database, any PHP directly in the HTML won’t get run; it’s not a .php file so it doesn’t trigger the PHP interpreter. However, snippets themselves can have HTML with inline PHP as is normal with .php files. I’m also pretty sure that if you use a snippet to include your template (the Manager’s template field only has a snippet, and that snippet only has the include directive) the file that is included can be HTML and inline PHP.
Quote from: johnywhy at May 15, 2011, 01:45 AM
hey, wait, i got GET workin’!
snippet:
<?php
echo 'Hello ' . $_GET["name"] . '!';
?>
so why do i need the geturlparam plugin?
You don’t necessarily, but it will sanitize the input for you and let you limit the values. I think it’s a snippet rather than a plugin.