How to display the content of the CMS page

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

How to display the content of the CMS page

Post by ahmed31916 » 13 Jun 2022, 04:11

Hello,

I made a new cms page for "about us" page. I added this to the web.php:

Code: Select all

Route::group(['prefix' => '{site}', 'middleware' => ['web']], function () {
    Route::match(['GET', 'POST'], '{path?}', 'App\Http\Controllers\AboutUsController@index')
        ->name('about_us')->where( 'path', '.*' )->where( ['site' => '[a-z0-9\-]+'] );
});
and in "AboutUsController@index":

Code: Select all

public function index()
{
	return View::make( Shop::template( 'page.aboutus' ), ['page' => 'page-aboutus'] );
}
and in "page.aboutus" :

Code: Select all

<?= $aibody['cms/page'] ?? '' ?>
and in config/shop.php:

Code: Select all

'page' => ['page-aboutus' => ['cms/page'],]
Now, when I add a new cms content in admin panel for this route "/aboutus", the content doesn't appear in "page.aboutus" page. Why?

User avatar
aimeos
Administrator
Posts: 7884
Joined: 01 Jan 1970, 00:00

Re: How to display the content of the CMS page

Post by aimeos » 14 Jun 2022, 19:19

Your index() method is wrongly implemented. Have a look here:
https://github.com/aimeos/aimeos-larave ... hp#L32-L44
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
ahmed31916
Advanced
Posts: 148
Joined: 14 Apr 2022, 12:15

Re: How to display the content of the CMS page

Post by ahmed31916 » 15 Jun 2022, 03:31

Thank you, but why I should to pass a "?path=" parameter?
Can I overwrite the Standard class for the CMS, in my extension? (I asked this question because the CMS code and template inside grapesjs package).

User avatar
aimeos
Administrator
Posts: 7884
Joined: 01 Jan 1970, 00:00

Re: How to display the content of the CMS page

Post by aimeos » 16 Jun 2022, 11:10

If you've install the CMS extension, you can already create pages with a custom URL segment (path). The latest Aimeos package already contains working code so there's no need to create an own controller for content pages:
- https://github.com/aimeos/aimeos-larave ... #L270-L279
- https://github.com/aimeos/aimeos/blob/m ... op.php#L40
- https://github.com/aimeos/aimeos-larave ... hp#L84-L86
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply