Comments (10)
it works. thank you so much.
from laravel-pagebuilder.
When the $data
is rendered it is a full html structure, so I suggest not to pass it to a blade view file since it is already a full webpage. There are multiple ways to render the data from one page, you could do this:
use PHPageBuilder\Theme;
use PHPageBuilder\Modules\GrapesJS\PageRenderer;
use PHPageBuilder\Repositories\PageRepository;
public function viewPage($pageId)
{
$theme = new Theme(config('pagebuilder.theme'), config('pagebuilder.theme.active_theme'));
$page = (new PageRepository)->findWithId($pageId);
$pageRenderer = new PageRenderer($theme, $page);
$html = $pageRenderer->render();
return $html;
}
from laravel-pagebuilder.
I have copied the function but there is an error.
Error
Call to a member function findWithId() on null
http://127.0.0.1:8000/admin/pages/1
from laravel-pagebuilder.
On what line of the code does this error occur? Can you further trace where it went wrong, this error does not reveal to me what causes it.
from laravel-pagebuilder.
public function findWithId($id)
{
return $this->createInstance($this->db->findWithId($this->table, $id));//the error is occur this line
}
from laravel-pagebuilder.
Ok that shows me what is the issue, the DB is not instantiated. This makes sense because this is done when we create a PHPageBuilder instance, which we did not do. I just committed a fix to the master which will be part of the next release.
For now you can add this to the boot method of your App\Providers\AppServiceProvider
:
$this->app->singleton('phpPageBuilder', function($app) {
return new PHPageBuilder(config('pagebuilder'));
});
$this->app->make('phpPageBuilder');
from laravel-pagebuilder.
from laravel-pagebuilder.
Yes everytime you create an instance of a class that is not inside the current folder, you need to include it with use [namespace]
. If you switch to an editor like PhpStorm it warns you of this and helps to fix it. In this case you need to add:
use PHPageBuilder\PHPageBuilder;
from laravel-pagebuilder.
public function viewPage($pageId)
{
$data=DB::table('pagebuilder__pages')->where('id',$pageId)->value('data');
return $data;
}
I get the page data from the function, How can I render the data into blade?
When the
$data
is rendered it is a full html structure, so I suggest not to pass it to a blade view file since it is already a full webpage. There are multiple ways to render the data from one page, you could do this:use PHPageBuilder\Theme; use PHPageBuilder\Modules\GrapesJS\PageRenderer; use PHPageBuilder\Repositories\PageRepository; public function viewPage($pageId) { $theme = new Theme(config('pagebuilder.theme'), config('pagebuilder.theme.active_theme')); $page = (new PageRepository)->findWithId($pageId); $pageRenderer = new PageRenderer($theme, $page); $html = $pageRenderer->render(); return $html; }
Where write this code ?
from laravel-pagebuilder.
You can make a Laravel controller method with this snippet.
from laravel-pagebuilder.
Related Issues (20)
- Migration Error HOT 5
- Can't run php artisan migrate HOT 3
- unable to add bullets in PB editor HOT 1
- Error when run migrate in laravel 8 in version phpbuildier 0.22.0
- pagebuilder HOT 1
- Migration error [Laravel 8.8, pagebuilder 0.24] HOT 3
- database mess
- You pushed Laravel library 3 years ago. Do you believe, this library will work on Laravel 10? HOT 3
- SQLSTATE[42S22]: Column not found: 1054 Unknown column 'meta_title' in 'field list' HOT 2
- How can I get Grapejs default block components inside my block HOT 2
- Tutorial about integrating PHPageBuilder into a Laravel project HOT 1
- Call to a member function select() on null Error
- Cannot drag & drop, white screen with nothing to do HOT 2
- No publishable resources for tag [config]. HOT 6
- No publishable resources for tag [config] HOT 2
- Issue on block separation using tailwind CSS HOT 2
- /admin not found, but records url as /in
- Admin Login returns 419 Expired
- incompatibility with laravel 10 and 11
- how do i implement this app with already having admin route and lots of users.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-pagebuilder.