I’d like to know how to integrate existing PHP script in Modx
Suppose that I’ve some PHP pages (MVC) that show records in a table and make some changes in table, another page that read values from a web services.... a these page have a MVC structure and I like to integrate these pages in Modx Layout, attach the code of my view and keep Model and Controller.
Thanks
to include php in modx just create a snippet, then call the snippet into the page, for example if you create a new snippet and call it mysnippet add [[mysnipper]] to either the page content or template.
-
☆ A M B ☆
- 24,524 Posts
You will in most cases be able to simply have a single include line in your MODx snippet to include your existing .php file. Sometimes it needs a bit of tweaking, though, especially to properly format your code’s output.
Thanks for your replies, but suppose that I’ve 10 PHP pages (10 views pages) and other X pages for the controller.... these pages are linked (for example for read paramters during the page call) ... how can integrate this solution in ModX?
Thanks
-
☆ A M B ☆
- 24,524 Posts
Then the including snippet would need to have a conditional to determine which script to include.
Excuse but I don’t know what do you mean!
In snippet I can add PHP code
but if my "small PHP web application" is composed by many pages ... how can I do this?
Thanks
-
☆ A M B ☆
- 24,524 Posts
It depends on the application, and how it determines which page to display.
Suppose that I’ve these pages:
list.php
listmananager.php
the allow to show records
detail.php
detailmanager.php
that allow to show detail of each record, selecting a specific record of the list
in each row of list grid I’ve a link like this detail.php?ID=12 for open each detail page
I’d like to include the list of records page (in modx template) and when a user select a record open the detail page (in modx template)
Can you tell me the solution that I’ve to use?
Thanks
Please help me!!!
Are many days that I’m trying to resolve this probem?
Thanks
I think the starting point would be to create a MODx document for each php file. Each of those pages would have nothing but a call to its own snippet and that snippet would just have an include statement to include the one appropriate php file. You’ll probably need some tweaking to get that to work, but it may be easier than rewriting the whole application in MODx.
As an alternative, you could leave your whole original application as is outside of MODx, style it to look like the MODx site, and put links from one to the other.