Access CMS Content from JSON

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!
jafo66
Posts: 25
Joined: 06 Mar 2024, 04:42

Access CMS Content from JSON

Post by jafo66 » 15 Mar 2024, 22:47

Code: Select all

Php version: 8.2.15

Versions: 
aimeos/ai-laravel                  2023.10.5  
aimeos/aimeos-laravel              2023.10.8  
inertiajs/inertia-laravel          v0.6.11    
laravel/framework                  v10.48.3   
laravel/jetstream                  v4.3.1     
laravel/serializable-closure       v1.3.3     
spatie/laravel-ignition            2.4.2      

OS version: MacOs 14.4
Is there a way to access the actual HTML content that was created within the CMS admin area from the JSON API? I can use this to get the CMS entry: http://localhost:8000/admin/default/jsonadm/cms/2 but not the content.

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

Re: Access CMS Content from JSON

Post by aimeos » 18 Mar 2024, 09:40

Do you need the CMS content in the frontend or backend?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jafo66
Posts: 25
Joined: 06 Mar 2024, 04:42

Re: Access CMS Content from JSON

Post by jafo66 » 19 Mar 2024, 19:48

I'm thinking on the front end. We are building our own front end, but would love to be able to do small managed bits of content on the site that is edited by the admins.

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

Re: Access CMS Content from JSON

Post by aimeos » 20 Mar 2024, 11:34

For the frontend, you have to use the frontend JSON API:
https://aimeos.org/docs/latest/frontend/jsonapi/basics/

The resource is "cms", e.g. "http://localhost:8000/jsonapi/cms" and to get the content too, you need to include the text resources:
http://localhost:8000/jsonapi/cms?include=text
or more specific:
http://localhost:8000/jsonapi/cms?include=cms.text

See also: https://aimeos.org/docs/latest/frontend ... gn-domains
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jafo66
Posts: 25
Joined: 06 Mar 2024, 04:42

Re: Access CMS Content from JSON

Post by jafo66 » 21 Mar 2024, 04:17

Thanks for the information. The first URL works great, especially if I have an ID, I can get the specific content.

The second URL: "http://localhost:8000/jsonapi/cms?include=cms.text" doesn't seem to return anything different. You had said "more specifc", but I'm not following what it was supposed to do?

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

Re: Access CMS Content from JSON

Post by aimeos » 22 Mar 2024, 12:01

There was a bug in processing "cms.text" which is now fixed in the latest 2023.10 version of the aimeos/ai-cms-grapesjs package.

For CMS items it makes no difference but for e.g. products, it will returns only product texts if you specify "attribute,catalog,supplier,product.text" instead of the text items from the other related domains too.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jafo66
Posts: 25
Joined: 06 Mar 2024, 04:42

Re: Access CMS Content from JSON

Post by jafo66 » 22 Mar 2024, 19:50

Got it, that makes sense.

Post Reply