Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to make an MVC app fit into wordpress

Posted on 2014-10-12
2
Medium Priority
?
211 Views
Last Modified: 2014-10-13
I have an MVC application which we need to show inside of wordpress.
In other words, we'd like it to fit nicely into the standard wordpress look and feel.

Can this be done and if so, what should I be looking for in order to accomplish this?
0
Comment
Question by:projects
2 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 2000 total points
ID: 40376292
Can this be done

Yes.

and if so, what should I be looking for

There's lots of different ways to go and the exact answer would require a fairly intimate knowledge of the MVC app, so this is, by necessity, a broad answer.

The two easiest ways to integrate non-WP content into a WP site are:

1) Bring the WordPress theme elements into a non-WordPress page
2) Use a custom page template to call/execute your custom code.

For #1, the code would look like this:

<?php
require('../wp-load.php'); // make sure this points to the WordPress Core properly
get_header();
?>

Your other stuff here

<?php get_footer(); ?>

Open in new window


For #2, go to your theme files and copy page.php to a new file (page-whatever.php) and then edit it to add the MVC calls and other code from there.

For both of these solutions, the biggest issues you will have will be the WordPress environment conflicting with the MVC environment.  For example, WordPress doesn't allow access to $_SESSION by default but your MVC might need it.  So to get around this, you would have to add session support to WordPress via functions.php:
add_action('init', 'session_manager');
function session_manager() {
    if (!session_id()) {
        session_start();
    }
}

Open in new window


There will be other conflict, usually related to variable scoping.  Good luck.
0
 

Author Closing Comment

by:projects
ID: 40378715
Thank you, this says it all perfectly.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question