GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.38k stars 4.06k forks source link

Grapejs and WordPress #717

Closed endersaka closed 6 years ago

endersaka commented 6 years ago

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?

artf commented 6 years ago

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 :)

endersaka commented 6 years ago

@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. :-)

artf commented 6 years ago

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)

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.