How can I call the MODx API from a standard HTML (non-MODx) page? Why would I want to do that? I have 1,000 picture pages from before I migrated to MODx. I’d like to update the navigation sections on their html template so at least the navbar automatically updates when I add new categories to MODx. Here’s an example I tried (that failed):
<script language="php" src="/index.php?runSnippet=DropMenu&orderBy=menuindex,menutitle&startDoc=`0`&levelLimit=`1`" type="text/php"></script>
A couple questions: Am I even pointing to the right .php file? Can I put an argument like "runSnippet=DropMenu" with args delimited by "&" and expect the result to be placed on the html page?
-
MODX Staff
- 10,725 Posts
You can’t, at least not in any way resembling what you have posted. You can use the MODxAPI add-on in the repository (and in the future you can use the MODx "API" directly, without the add-on) inside of external PHP files, but you cannot make calls to PHP using client-side script tags in HTML pages as you indicated; PHP is not a client-side scripting language. It’s interpreted by the server.
Thank you for the help; that’s what I needed to know. So, the modxapi.php is the file to point to but it will only work from a .php page and not a .html page.