givanz / VvvebJs

Drag and drop page builder library written in vanilla javascript without dependencies or build tools.
https://www.vvveb.com/vvvebjs/editor.html
Apache License 2.0
6.91k stars 1.59k forks source link

Save dosnt work | Help please #282

Closed vinumweb closed 1 year ago

vinumweb commented 1 year ago

Hi everyone! Im here to create a system for my customers to create and maintain theyre own website. But i have a problem. I downloaded vvvebjs (NOT THE WHOLE CMS) from github but when i try to save it says undefined array key, and failed to open stream: no such file or directory.

How do i fix this? btw. Thanks alot for this amazing pagebuilder! image

givanz commented 1 year ago

Hi

From the error message it seems that file is not sent through ajax to save.php, can you please check if all parameters are sent on save in the browser developer console (Press F12) > network tab?

It should have file like in the attached screenshot.

Screenshot_2023-01-21_22-35-40

vinumweb commented 1 year ago

Hi. Can we please chat on discord?

vinumweb commented 1 year ago

And yes it does show the file

vinumweb commented 1 year ago

image

givanz commented 1 year ago

Hi. Can we please chat on discord?

Sorry, I don't have a discord account.

In your screenshot there is a request save in red at the end of the list, can you please check it? I think there are two requests made one correct and another that is missing data, the one in red.

Are the changes made to the page saved? if you refresh the page the changes persist?

Is the code unchanged? I can't reproduce this error with the code from github.

vinumweb commented 1 year ago

Hi. Please remain on the page. Its quite urgent. im sorry.

Yes i notices the red one too. The page is unsaved. Here is a pictture of the red image

givanz commented 1 year ago

Can you also check response tab to see if it matches the error message that is shown in the alert to make sure that is request is causing the error?

Also please provide a screenshot with console tab like the one bellow for the failed request to see what code is calling this request.

Screenshot_2023-01-21_23-15-31

vinumweb commented 1 year ago

It matches yes. And thank you for taking youre time to help me!

vinumweb commented 1 year ago

Here is the console image

vinumweb commented 1 year ago

Omg i just found out its because of my .htaccess file. IM SO SORRY MATE. Thanks for this amazing editor and have a great rest of youre day <3 love

vinumweb commented 1 year ago

Oh but now new problem. sorry. When i try to create a new file it gives me this: image image

vinumweb commented 1 year ago

It seems that it cant create the file itself if it dosnt exist How do i make it create it itself?

vinumweb commented 1 year ago

Ok. ok ok. It cant create a folder itself. How do i make it able to do that? And when i create a new page with a existing folder i save it but then when i reload the page it dosnt show up

vinumweb commented 1 year ago

bro im such a idiot. Im so sorry for wasting youre time. Its because i needed to open .php not .html. Tahnks for this project!

givanz commented 1 year ago

Its because i needed to open .php not .html

To load new files you need to use the php version that loads the file list.

It cant create a folder itself. How do i make it able to do that?

In save.php replace

$file = sanitizeFileName($_POST['file']);

with the following code

$file = sanitizeFileName($_POST['file']);
$dir = dirname($file);
if (!is_dir($dir)) {
    echo "$dir folder does not exist\n";
    if (mkdir($dir, 0777, true)) {
        echo "$dir folder was created\n";
    } else {
        echo "Error creating folder $dir\n";
    }
}

I'm glad it works.

vinumweb commented 1 year ago

Hi again @givanz Can you please help me. How do i save the files and create a new page to a different directory. This is how my files are

My-project
-customers 
--customerswebsite(The files should be saved in this directory)
-admin
--vvvebjs (here is the folder with vvvebjs all content inside)
---editor.php
---save.php (save.php should save all files to customers folder)

Thanks in advance.

givanz commented 1 year ago

You need to edit save.php and editor.php to change the paths, by default the file is saved to the folder provided in the create page dialog that must be on the same level as save.php.

You need to delete the folder input from the dialog inside editor.html and in save.php replace __DIR__ which is the root folder where save.php is located with the root folder where you want to save the file My-project/customers/customerswebsite.

You will also need to change the paths in in editor.php with the new paths, by default the files are read from demo and my-pages.

Replace {my-pages/*.html,demo/*\/*.html, demo/*.html} with {My-project/customers/customerswebsite/*.html}

The php files are basic examples on how to save the content and are provided to show how to get content from ajax request and load the file list for easier integration into a CMS or website.

If you need more complex functionalities and don't want to integrate the library into a CMS or develop your own you can use Vvveb CMS.

vinumweb commented 1 year ago

Hi @givanz . Thanks a lot for the answer. I actually found out myself using ChatGPT. The system is now working and it is insane! You really deserve a prize!

Thanks a lot for this amazing project.

-Peter, VinumWeb.com