HansSchouten / PHPageBuilder

A drag and drop page builder to manage pages in any PHP project
https://www.phpagebuilder.com
MIT License
721 stars 177 forks source link

Help pls, how can i output the html to page? #135

Open FidoAlex opened 1 year ago

FidoAlex commented 1 year ago

Great job with this project, god bless you!

I have a php bootstrap template and i don't know how to output the html code to my homepage (frontend) saved from phppagebuilder to mysql , can u help me pls? in pages i have a lot of json output and i don't have a clue how to grab only the html generated code, thank you!

HansSchouten commented 1 year ago

Glad to hear you like the project. This snippet is where a page is rendered into HTML: https://github.com/HansSchouten/PHPageBuilder/blob/master/src/PHPageBuilder.php#L353

FidoAlex commented 1 year ago

Thank you for your reply, i'm new with this and i'll appreciate if you can show me an example for implement into a simple php page, ps: i don;t use routes in my website, i use only simple url parameter like ?p=homepage - only in the admin of phppagebuilder area i use the default routes. Thank you

HansSchouten commented 1 year ago

I use the snippets shown here: https://github.com/HansSchouten/PHPageBuilder#integrate-into-existing-project-or-framework

$builder->handleRequest(); will render the page based on the current URL. If you follow the calls there, it will reach the default router (DatabasePageRouter) over here which determines the correct page from database that should be rendered for the current URL.

By creating a custom class that implements the RouterContract and configuring your implementation as the active router in the config file it is possible to create custom matching based on your URL parameter: ?p=homepage.