Composite Region in Site Settings not Deserializing the respective record Id #1925
-
PiranhaCMS version: 9.2 So we implemented the composite region for our custom site as is stated in the documentation and we use it to configure some site-wide messages (different messages for every site as well) that have to appear on every page on our user facing application. The issue is that each of the regions in the list doesn't have an Id that could be serialized for the view model rather each field in the region has its own and even using those isn't possible as they don't get deserialized by the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi there! First, what’s the link to the docs with the Composite region that you’re referring to? Now let’s get into how content data is stored. There’s no separate table for regions which is why there’s no Id. On the other hand the name of the Region is unique for a content type (since it is usually derived from a class property) and is therefore equivalent to an Id. The Id of a field is not serialized with its values, but since fields in regions are also defined by class properties the combination of region-name & field-name is unique per content type. Best regards |
Beta Was this translation helpful? Give feedback.
-
Hello, first of all we were referring to this documentation and as stated this works completely fine, we have an IList where CustomModel has a couple of SimpleFields ranging from DateField to StringField. We did notice that the DB model doesn't hold region Id's per se and that's kind of an issue (which we were able to work around). While the fields in regions do have different field names those aren't enough to identify a region, even if we ended up using the SortOrder as well the "Id" would be something like "RegionName-FieldId-1" which isn't unique across different sites or through time. If You take the example into account and if a user deletes the region from the site settings and adds a new one the new region would still have that same exact identifier even though its a completely new region. Now if the user has a cookie stored with the Id "RegionName-FieldId-1" they would never see the second index region on the site due to this limitation. We understand that this currently doesn't work as we wish it to but it might be a good idea to add a relation table for regions in the DB model so that they would each get a unique identifier in the future, as said we were able to circumvent this with a slight hack without adding any DB migrations but just as food for thought maybe this is something You would like to add to the roadmap at some point. |
Beta Was this translation helpful? Give feedback.
-
Another possible workaround could be to add a custom field that sets its own value to |
Beta Was this translation helpful? Give feedback.
Another possible workaround could be to add a custom field that sets its own value to
Guid.NewGuid()
if the value is empty. Then it could be rendered in the manager in the same manner as theReadonlyField
(https://github.com/PiranhaCMS/piranha.core/blob/master/core/Piranha.Manager/assets/src/js/components/fields/readonly-field.vue). If you added this field to all of the regions that you need to handle the way you describe you would get a unique Id per region & region item for collections that you could use.