Integrating Wordpress with Spring MVC - wordpress

I'd like to have a Wordpress installation to serve blog content for my site under the directory /blog
My site runs on Spring Mvc and I'd like of course to maintain the basic layout (saying Header and Footer) of my site and integrate the wordpress blog on it.
What could be some approach to do this?
I'm using Tiles as my Template mechanism so I was basically thinking to handle /blog request with my requestDispatcher and internally forward the request to Wordpress, then take the response and stream it inside the Content Tile section of my pages so to keep the basic look of my site for header and footer.
But I'm not sure of this approach.
How are you doing this? I can see they also have some RestAPI

If you simply want to use WordPress as a content management system and Spring MVC + Tiles to display your blog, then exposing your WordPress pages and posts with an API plugin such as WP Rest API or JSON API sounds like a great solution. This is how we manage our faq/contact/terms and conditions/etc. pages.
To make it faster, we synchronize (with a CRON job) each 30 minutes the content between our application database and the WordPress instance so that when the page is requested by an user the content is not pulled from WordPress but from the application DB. And then to make it even faster we created an Hibernate cache that lasts 30 minutes for this kind of data.

I have recently written a library in Spring, that uses WP REST API plugin to fetch content from WordPress. You might find it useful. Here is blog post on how to integrate Spring Boot and WordPress.

Related

Create blog on Hybris

I need to know if there is some module or something like that in Hybris to create a blog or I need to create a wordpress in subdomain(Bad idea because the web actually is a subdomain xd)?
Unfortunately there is no OOTB Hybris Blog Engine. Utilizing only OOTB you can build a blog using Content Pages. So for example you can create a content page which will represent a particular blog article, also you can create a new component which can fetch all Blog Content Pages and display them in the chronological order.
Based on my experience building a custom blog platform on the top of Hybris is not the best idea. So usually clients are implementing Blog using a wordpress as a blog engine. The integration between hybris and wordpress is usually done through Wordpress REST API. Articles can be fetched from the wordpress instance and displayed on hybris site without having a separate subdomain.

Use Wordpress as CMS and access content via REST API

I have used Contentful before to host content and access it in my application via REST. It works great however it is not free.
I am trying to find out if I can host my app's content similarly on Wordpress and access it in my app using its REST apis.
Does anybody know if we can and how? It is not that straight forward to figure out on their website.
PS: I don't care about the security about the website content.
wordpress has an embeded REST API, this can be done easily, check the REST API Handbook in the following url here: https://developer.wordpress.org/rest-api/

Mixing Wordpress eCommerce site with external login based Vue Frontend Best Practices

I am new to web development and and would like advice about what is the usual best practices to achieve what I am trying to do.
I am in charge of writing a frontend app using Vue. This frontend will require a login to access the app. The app will be hosted on Amazon.
However we are also wanting to build an eCommerce site in Wordpress or equivalent that sits on the root of the website, (eg www.mywebsite.com) with the app accessible through a "sign in" button. If the user presses the sign in button we want the location bar location to not change from the website they are on (www.mywebsite.com), even though the Wordpress site and Vue frontend may be stored on different locations/domains.
If the site is made in Wordpress, we can get another developer to do that webpage for us, while I work on the frontend. However we want the experience to be relatively seamless between connecting to the wordpress root site, clicking on the sign in button and being taken to the Vue frontend.
Is this possible? Do both sites have to be hosted on the same server for it to work (eg an Amazon EC2 server which hosts two webpages, the wordpress one and the vue one)?
Or can the wordpress put a link to the Vue frontend which doesn't change the web location to the user?
Or (worst case scenario) do we need to make both webpages in Vue as one Vue application, some pages requiring login to access and others not?
Thanks kindly for any assistance.
So in order to use Vue and WordPress together, you can either write 2 separate applications. One for the Frontend and one for the Backend, which is perfectly fine or you can simply write a WordPress Application with a Vue Theme.
This is how this could look like:
WordPress Backend
You can use a normal WordPress backend, where you can build the architecture you want to. In addition, you need to set up the REST-API Wordpress provides. So this also means, just use plugins which support it. Otherwise, you would need to write custom endpoints. For example, Woocommerce would be a good e-commerce plugin, since it supports the API.
Learn more about it here: https://v2.wp-api.org/
Of course, you can host your WordPress installation on Amazon. Here is a good guide for that: https://aws.amazon.com/de/getting-started/tutorials/launch-a-wordpress-website/
Notice: The REST-API is available in core since 4.7. If you are using an older version you would need to install a plugin.
WordPress Frontend
In order to create your Frontend, I'd recommend you to make a custom theme. Since you are just serving static files this can be done pretty easy. But still, you don't need to reinvent the wheel.
There's a really good starter theme out there: https://github.com/EvanAgee/vuejs-wordpress-theme-starter
It comes with all the stuff you need to get started and since it is just a theme, you can simply set up a usual WordPress hosting without handling Domains of multiple applications.
In order to get the data from the Backend, you would simply make calls to the REST-API. Here's an example: https://github.com/EvanAgee/vuejs-wordpress-theme-starter/blob/master/src/api/index.js

SPA with content management

I would like to build Single Page Web Application (SPA) with React.js.
Application would need some Content Management System for back-end. I was thinking to use WordPress and their REST-API's but I don't know how to retrieve data from my wordpress installation.
Back-end and front-end would be in different domains so just building WP theme with React.js wouldn't work.
Basically, I don't know how to call and populate data from wordpress to my front-end.
I would need someone to point me to the right direction. And, maybe recommend easier CMS to use in this task.
Actually it is very easy to access your WordPress website data through HTTP REST API
Here you have the full documentation on WordPress REST APi
http://v2.wp-api.org/

How do I make Wordpress and an ASP.NET MVC 2webapp appear as one app to the end user?

I want to use Wordpress as a CMS for our domains content pages, and also provide links to and from CMS and our service which is an asp.net MVC 2 app, and I would really appreciate some guidance on this subject:
The first approach that comes to my mind is to bind my wordpress site to "thedomain.com" and then bind the service to "service.thedomain.com", and just have them point to the different websites in IIS. In my opinion it does not provide a seamless experience since we are effectively moving from one domain to another when navigating between MVC and wordpress.
How would you solve the task of making a wordpress app and an MVC app appear to be one?
A co-worker came up with an interesting solution to a similar issue and to solve it he wrote a theme in WP that shows all front-end results in JSON. Then, he used ajax/js to pull in content by sending a link to the WP server and pulling back in the JSON-formatted results. I have been meaning write up a blog post about it but the concept should get you started.
Basically, a main-server-page loads all the HTML then hits the wp-server and pulls in the necessary content. The main issue with doing it this way was the page would be empty if the user disabled JS or something else went wrong, but we never had that issue on a lightly-used server.

Resources