Solved

How to make an MVC app fit into wordpress

Posted on 2014-10-12
2
175 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 500 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress Uncaught TypeError: $container.imagesLoaded is not a function 36 32
hasing a url 16 24
Google Maps API and PHP 25 27
PHP AJAX Wordpress 9 19
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

776 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