Thanks for the reply, @aurelie
I don’t have any intention of using the UUID with repeated items. It’s only to be utilized with bound-text elements.
I am hacking together a headless CMS to allow my team to freely edit copy on our site without requiring a full re-build.
I have two tables,snippets
and element_snippet_map
:
CREATE TABLE "web_content"."snippets" (
"snippet_id" uuid NOT NULL DEFAULT uuid_generate_v4(),
"content" text,
"description" text,
PRIMARY KEY ("snippet_id")
);
CREATE TABLE "web_content"."element_snippet_map" (
"element_id" uuid NOT NULL,
"snippet_id" uuid,
"typography_id" uuid,
"description" text,
CONSTRAINT "element_snippet_map_snippet_id_fkey" FOREIGN KEY ("snippet_id") REFERENCES "web_content"."snippets"("snippet_id"),
PRIMARY KEY ("element_id")
);
-- Column Comment
COMMENT ON COLUMN "web_content"."element_snippet_map"."element_id" IS 'This is the UUID from WeWeb';
In WeWeb, I have configured the following
-
collection site-snippets
: an array of objects of the form
[
{
"element_id": "UUID1", "content":"This is the copy for UUID1"
},
...
{
"element_id": "UUID99", "content":"This is the copy for UUID99"
}
]
-
variable snippet-lookup
: a dictionary derived from site-snippets
of the form
{
"uuid1":"this is the copy for UUID1",
...
"uuid99":"this is the copy for UUID99",
}
Whenever I create a new text element in WeWeb that should be customized with our copy, I create a new record in element_snippet_map
, setting element_id
(the primary key) equal to the WeWeb’s element UUID.
Then, I would bind the text to snippet-lookup[this.elements.uuid]
I currently have it working for page-specific copy - because the page_id
is exposed in the WeWeb Editor.
e.g., each page has a record in element_snippet_map
, and I can populate the page’s title via snippet-lookup[context.page['id']]
(or snippet-lookup[CurrentPage['id']]
, same thing)
With those details in mind, are you aware of a reasonable method of obtaining CurrentElement['id']
or something similar?