madeyourday/contao-rocksolid-custom-elements

Loading data from a custom elements

biowebfr opened this issue · 1 comments

Contao 3.5

Hi,

Can you tell me please how I can load data from a custom elements (programmatically)?
Since this is dynamic I suppose I can't use a simple Model object like with any other DCA.
But since I know my element name and its records IDs I guess there is a way to load data from that information :)
I need this so I can freely load my element data and transfer them to templates as from a parseTemplate hook for instance.

Thanks.
Cheers !

ausi commented

You can use the following code to access the data of a custom content element:

$element = \ContentModel::findByPk($id);
$elementData = json_decode($element->rsce_data);