I had a site exactly like what you are describing written in Etomite, another Open Source CMS. When I made the move to WordPress last May, I opted to hand create each person-details page to avoid constantly revising the external (i.e. – non-WordPress) database structure whenever I discovered a new type of info I wanted to add for one or more people. Plus, I didn’t want to build my own database-based picture gallery like I had to in Etomite, opting for WordPress’s built-in gallery.
But I retained the automatic linking from the All-People page to the Person-Details page by checking if a WordPress child page existed with the person’s name (which I used as the Page Title).
I’m not saying that what you propose isn’t possible. I’m just saying that I chose my approach as it was easier and more flexible. Though I did do a lot of Copy and Paste.
Thanks for the reply.
I really want to avoid having to create that many individual pages, mainly because the database of people is constantly being updated by an external admin interface (which we custom built). It wouldn’t be practical to switch over, UNLESS there were a way to let it create pages automatically (maybe by accessing the WordPress database directly?) But that sounds like a huge PAIN.
Alternatively, I could create a custom directory with PHP files that call the WordPress header and footer files, and just keep that directory separate.
Honestly, I’m leaning toward the second solution. My ONLY HESITATION is that say for the Google XML Sitemap plugin, it wouldn’t be aware of these pages, would it? Might make the site fragmented, which I want to avoid. On the other hand, the shopping cart area of the site will ALSO be outside of WordPress….
Anyone else have any input?
You should be able to create a new theme template for ‘people’ and feed it an url something like ‘people/?person=person_1’ then have a function in the template connect to your external database and grab the person’s data. You should be able to connect to any database you want so long as you have the right login, pass, and privileges. Then use WP_Rewrite to get the user friendly URL structure you want.
Hey man just wanted to say THANK YOU for this great advice.
I think that is definitely what I’m going to do…
You can connect to another database using a new wpdb object..
// Example db connection
$my_db = new wpdb( 'db_user', 'db_password', 'db_name', 'host' );
// Example query using new db connection
$results = $my_db->get_results("SELECT x,y,z FROM a WHERE b = 'c'");
// Example loop to follow.
if( $results ) {
foreach( $results as $item ) {
echo $item->x; // Echoes the data from the x col in the query
echo '<br />';
echo $item->y; // Echoes the data from the y col in the query
echo '<br />';
echo $item->z; // Echoes the data from the z col in the query
echo '<br />';
}
}
If you’re querying a seperate database, hopefully that will help..
You can also see a similiar example here, which inspired the example above.
http://wordpress.org/support/topic/307945?replies=8
Info on the wpdb class here(although no example of using a new wpdb object):
http://codex.wordpress.org/Function_Reference/wpdb_Class