Quote from: ian_m at Sep 04, 2007, 04:46 PM
I have an existing site which has a very simple php script which pulls some info out of one table in a database on just one page, what I would like to do is convert this site to MODx but I am not sure how to intergrate this with MODx.
1. Should I copy the table into the modx database so that the content will become searchable.
2. I guess I need to put the php into snippet, but is there anything for the connection to the database I need to know about or do I leave it the same as on the non MODx site like this $dbcnx = !@mysql_connect(’localhost’, ’root’, ’password);
3. Am I so out of my depth should I not bother.
Cheers
Ian
If you wrote the original php code, you’re almost certainly up to doing this.
You should make a snippet and put it a call to it on your display page, e.g.
It could contain your original code (and maybe you should to start with that) but you might also want to consider putting the data into a MODx table and using the MODX Database API (DBAPI) to access it. See
http://www.modxcms.com/dbapi.html
Down the road, you might want to modify the snippet to take additional parameters. That way you can have different displays of the data on different pages, let the user select how things should look, or show a debugging version. All these will involve calling the same snippet but with different parameters, like so:
[!yourSnippetName? &fullDisplay=`yes` &debug=`no`!]
Look at some of the existing snippets in MODx to see how to do that.
Bob