These are chat archives for GetmeUK/ContentTools

12th
Nov 2015
Benjamin Intal
@bfintal
Nov 12 2015 00:02
@JGallardo CT is essentially an editor and is meant to be integrated into something, e.g. like TinyMCE
@JGallardo For example I've been creating a front end page builder for WordPress using CT
Benjamin Intal
@bfintal
Nov 12 2015 00:17
So the security is really dependent on your system :)
Juan Gallardo
@JGallardo
Nov 12 2015 00:17
do you have an idea about how the demo page was built? it makes it seem so easy
Benjamin Intal
@bfintal
Nov 12 2015 00:21
For the demo page, it's just CT included and initialized. If you got downloaded the repo, it's like the sandbox folder in there.
Juan Gallardo
@JGallardo
Nov 12 2015 00:24
but what about how they save?
Benjamin Intal
@bfintal
Nov 12 2015 00:24
In the demo there's no saving
Generally saving is done via ajax. In my project, CT is only included when logged in so only they can edit. Then when saving credentials are checked first.
Juan Gallardo
@JGallardo
Nov 12 2015 00:27
lets say i just want to make a quick practice project. How can i save to a file :)
i read the tutorial but apparently missing something
Benjamin Intal
@bfintal
Nov 12 2015 00:29
You mean the back end? you can get the content being saved with something like $_POST['main-content']
Juan Gallardo
@JGallardo
Nov 12 2015 00:29
sorry for this total newb question but where exactly does that go? I am making a quick repo because not sure how this all ties in
Benjamin Intal
@bfintal
Nov 12 2015 00:30
In the saving tutorial in the site, you'll see this line: xhr.open('POST', '/x/save-page');
that corresponds to the script that should receive the data for saving
so you can have something like xhr.open('POST', '/save-test.php');
then in your save-test.php just do a var_dump( $_POST );
you'll be able to see in your browser dev console (network tab) the script being called when you hit the save button along with the dump
@anthonyjb perhaps this simpler example of just showing the content being saved after clicking can be included in the tutorial?
Juan Gallardo
@JGallardo
Nov 12 2015 00:45
ok that makes sense. But I currently cannot visualize how this all ties together. Like if someone asked how to make a cake and someone responded with "sugar, milk, bake"
Benjamin Intal
@bfintal
Nov 12 2015 00:46
lol
Juan Gallardo
@JGallardo
Nov 12 2015 00:46
working on that repo. i really appreciate you taking time to help out :)
Benjamin Intal
@bfintal
Nov 12 2015 00:46
is it only the saving part?
Juan Gallardo
@JGallardo
Nov 12 2015 00:46
yeah that is the part that I am stuck on
i understand the overall message you are saying. But then writing all this in the places it needs to go is where I am stuck
Benjamin Intal
@bfintal
Nov 12 2015 00:47
in the example I said above..
in save-test.php, you get the content being saved there. Then you can do whatever you want with it
For me I'm saving it in the database
so that's in save-test.php too
that's it :)
Anthony Blackshaw
@anthonyjb
Nov 12 2015 01:18

@JGallardo if you're saving to file then you;ll need an equivalent in PHP to the def save_page(): method in the Saving strategies tutorial. That method basically does the following:

  • Accept a POST from the client containing a map of region names to region content serialized as JSON.
  • Load the associated HTML file (the one relating to the page being edited) as a string
  • Use regular expressions to look for special comments within the HTML that mark up the start and end of an editable region.
  • Each region name is searched for, so for example if the region name is article_body then we search for <!-- editable article_body -->...<!-- endeditable article_body -->with the HTML string and replace it with the content in our region name to content map received from the server.
  • Once the content for each region has been replaced then we save the HTML string into the HTML file we read it from.

Does that help clear the process up? I can't see any server-side code in the pastebin you try to implement the steps above in PHP I'll gladly review any code and try to help (you'll have to forgive my limited PHP knowledge).

@bfintal Yeah I think I should add a note to the tutorial saying start by just printing out the variables you receive from the server as you suggested.
Juan Gallardo
@JGallardo
Nov 12 2015 06:40

ok so i don't have too much experience with databases :/ i usually get stuck somewhere with a gap in information. Which is what is happening here.

I created this test project. what do I need to modify to make this actually save?
https://github.com/JGallardo/package-mules

I have the site deployed here.
http://packagemules.com/
Bizley
@bizley
Nov 12 2015 09:56
@anthonyjb How is this bower/npm package going? ;)
Juan Gallardo
@JGallardo
Nov 12 2015 16:24
getting more excited about this tool as i continue learning it haha