Express Configuration on Installation

Permalink
Hello Community

I love the new Express feature in Concrete 5.8+. But the documentation seems to be realy bad on some points. Mostly I have a problem of finding die API-Documentation of C5.8 . Well this brought me to the question: Is it possible to setup complex Express-Objetcs programmaticall / in Code? In my case, i use those Express-Objects in my Theme and I would like to package the theme. Since automisation is awesome and I want to prepare / setup the Express-Objects directly during installation. Since Express is in my eyes future-proven I would like to keep the setup as it is and not find some other way to solve the problem without Express.

Thank you very much for your support.

Regards
Bigsisl

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi bigsisl,

"Yes, you can programmatically create express objects.

Here’s an example of the syntax for programmatically creating express objects that’s coming in 8.1 (and currently in the develop branch):"
$student = \Express::buildObject('student', 'students', 'Student');
$student->addAttribute('text', 'First Name');
$settings = new \Concrete\Core\Entity\Attribute\Key\Settings\TextSettings();
$settings->setPlaceholder('Last Name');
$student->addAttribute('text', 'Last Name', 'last_name', $settings);
$student = $student->save();
mnakalay replied on at Permalink Reply
mnakalay
Hey MrK
Do you mean that we can only use that code in 8.1 or will it work in 8.03 as well?
mnakalay replied on at Permalink Reply
mnakalay
Also I think you forgot the handle for the first attribute "First Name"
MrKDilkington replied on at Permalink Reply
MrKDilkington
@mnakalay

My response was a copy and paste of Andrew's answer to the same question on Slack.

I have not tried the code myself, it may have a typo in it.

I believe it is for 8.1+ only.
mnakalay replied on at Permalink Reply
mnakalay
Yes, you're right, I checked on Slack.
There is a way to do the same with the current version but the syntax Andrew gave and you pasted here is the nicer syntax only available from 8.1.

Thank you for your help
bigsisl replied on at Permalink Reply
How does the syntax look for 8.03 Version? Just curiosity?
mnakalay replied on at Permalink Reply
mnakalay
It's pretty long and each step has to be taken care of one by one, create an entity, set handle, plural handle, name...
Create a default form...

To have an idea of what it looks like, take a look at the add() function in
concrete\controllers\single_page\dashboard\system\express\entities.php


It's a lot of code.