Solved

How to make an MVC app fit into wordpress

Posted on 2014-10-12
2
166 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
Comment Utility
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
Comment Utility
Thank you, this says it all perfectly.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

WordPress is constantly evolving, and with each evolution appears to get better and better.  One of the big drawbacks prior to version 3 was that there was no way to be able to set up a custom menu from the backend. The Old Way Adding menus is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

771 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

10 Experts available now in Live!

Get 1:1 Help Now