Solved

How to make an MVC app fit into wordpress

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now