Grapejs and WordPress
Question
Hi. I think that this project is amazing. I especially interested in what is written in the "README.md" page, where you present an image depicting the process of connecting Grapesjs to a CMS, and I also read the issue #41 .
Despite all these informations I have a really poor knowledge of Grapesjs at this time. Though I am starting to imagine a way to implement a sort of PlugIn or Theme for WordPress, based on Grapesjs for editing.
Therefore I imagined a "starter" approach.
Loading some page/post or skeleton of them in to Grapesjs Let say we want to load the Home Page, in the case it is implemented, for example, as a front-page.php in your theme. In a WordPress template there are several different PHP calls. Actually there can be any kind of PHP code. But, for now, I want to consider only the most important call: get_template_part().
Loading the rendered page, the HTML from WordPress output, is (probably) not a problem for Grapesjs, but what if I want to keep track of where these calls are located to implement a sort of "smart" export?
So I thought to wrap get_template_part() in a custom Theme (or PlugIn) call that outputs some "placeholder" in case the request comes from a Grapejs editor page. Something like:
function my_load($slug, $name) {
echo "<div class=\"wp-template-wrapper\" id=\"wp-template-" . $slug . "\">";
get_template_part($slug, $name);
echo "</div>";
}
Does this solution make any sense to you? Or would you suggest any other approach?
Answers (3)
Hi @endersaka, thanks for your appreciations and suggestions. WordPress plugin for GrapesJS is definitely a good showcase of an integration with CMS but working on the project just in spare time and lack of deep knowledge of WP codebase was always an impediment.
Does this solution make any sense to you? Or would you suggest any other approach?
Honestly, I don't know if this is the best approach but definitely makes sense :)
@artf thank you for your answer. I have the same problem with spare time; though I will most probably give it a try. This morning I read the Components documentations more carefully and I see some opportunities. Since Components are actually stored in to the JavaScript data model of Grapesjs, I am not sure, but I see an oportunity to output something that affects Componets model instead of their in editor HTML representation. I'll continue my investigation and let you know as soon as I have some more clue. :-)
Great 👍
Since Components are actually stored in to the JavaScript data model of Grapesjs, I am not sure, but I see an oportunity to output something that affects Componets model instead of their in editor HTML representation.
Exactly, usually, you would store JSON object as it keeps more information about components and the HTML is just the "final product" which will be seen by the final user (not the wp's admin)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1688
on set model content property image and text written in content is not editable in grapejs canvas.
WARNING READ and FOLLOW next 5 steps, then REMOVE them before posting the issueFollow CONTRIBUTING Guidelines https://github.com/artf/grape...
Issue #1583
[Question] Amending urlStore and urlLoad dynamically.
Hi Everyone I'm loving Grapesjs so far - thanks for all your work on it. I'm in the process of trying to set up storage for whole page temp...
Issue #1311
[Question]: Initializing Canvas Scripts and Styles dynamically
Hello Grapejs team, Thanks for this wonderful project saved my time and so far I had great experience with integration and your community s...
Issue #1897
[Question] view vs code
Hello...and sorry for my english! First of all, congratulations for this fantastic framework. I'm trying to use GrapeJS to create my own wo...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.