Creating a Custom Non-Page/Block Content Type in Optimizely and Retrieving Data via the Content Delivery API

Vote:
 

Hi everyone,

I’m working on an Optimizely project (headless), and I have a specific use case where I need to create a new content type (similar to PageData or BlockData) that is neither a page nor a block. Essentially, I want to define a custom content type to hold data for items retrieved from an external API, but I don’t want to generate a separate page for each item.

Is it possible to push data into this custom content type and then retrieve it via the Content Delivery API?

Any advice or direction on how to approach this ?
do let me know if the question needs further clarification.

#330869
Oct 03, 2024 7:24
Vote:
 

What version of CMS and Content Delivery?

#330879
Oct 03, 2024 10:44
Faris - Oct 03, 2024 12:51
Hi Eric,
CMS v12 and Content Delivery v3
Vote:
 

Hi Faris,

Looking at requirements (use case) for your project an approach, you could use a custom content provider.

In order to do this you just need to create your custom content type and inherit from IContent.

I would way up the benefits of the custom content providers before you finalise your approach as it has some pros and cons.

Once you have the custom content provider implemented you should be able to use the Content Delivery API as normal to retrieve the data.

Let me know if you need anymore help on this.

Thanks

Paul

#330882
Oct 03, 2024 14:27
Faris - Oct 06, 2024 7:13
Thanks Paul for the help i will be reading on this 'content provider' and trying it out
Faris - Oct 06, 2024 14:28
Hi Paul, all seems good this is basically what we needed, although i do want your help regarding displaying the content in the UI for example the assets panel if possible

can you refer me to a documentation / guide to do the above i would greatly appreciate it :)
Faris - Oct 07, 2024 10:51
Thanks Paul, its what we were looking for i followed the below article to create a custom content provider
although its a bit outdated but we were able to make it work, and i would appreciate if the documentation had explained the content provider more,

https://world.optimizely.com/blogs/Per-Magne-Skuseth/Dates/2014/11/content-providers-101--part-i-introduction-initialization-ui--identity-mapping/
Vote:
 

Just like Paul sais you'll need the IContent inheritance, I do however wonder you you plan to find your content since the delivery API require a contentID or an URL to the content you are fetching. 

Wouldn't it just be more simple to create a custom API endpoint that will serve the items from your external API?

#330898
Oct 03, 2024 20:41
Faris - Oct 06, 2024 7:11
Thanks Eric i will be trying Paul's approach to resolve this issue, yes for this scenario maybe its easier to just create a custom endpoint although,
we have encountered multiple scenarios requiring the creation of custom content types in Optimizely. For instance, in one case, we needed to manage and display "events"—upcoming events for the company. To handle this, we created a new global setting called Event Settings, where event data was manually entered (not via an API).

We then utilized the ContentApiModelFilter along with the GetGlobalSettings method to retrieve this data, which was subsequently pushed to the Content Delivery API for consumption.

Our current challenge is figuring out an efficient way to define custom data structures within Optimizely that allow us to continue adding and managing data easily.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.