Referencing ${current.id} in repeaters?

23 views
Skip to first unread message

John White

unread,
Jul 16, 2022, 10:52:17 PM7/16/22
to structr
As part of my attempt to work with Relationships, I'm trying to display a BlogPost page and show the Categories the post belongs to.

My schema definition has the relationship as manyBlogPosts have manyCategories.

I'm trying to construct a BlogPost page that takes the UUID of the BlogPost object and displays the page. Throughout the page, I'm referencing ${current.name}, ${current.title}, ${current.text}, etc. However, when I construct a repeater div to show all the Categories, I run into problems.

What works: 
REST Query: BlogPost/<actual UUID of a BlogPost Node>/manyCategories

What doesn't work:
REST Query: BlogPost/${current.id}/manyCategories
Functional Query: find(${current.manyCategories})
Functional Query: ${current.manyCategories}

Any pointers on the proper way to do this?

John White

unread,
Jul 17, 2022, 2:33:36 AM7/17/22
to structr
For whatever reason, this is working now:

REST Query: BlogPost/${current.id}/manyCategories

Kai Schwaiger

unread,
Jul 18, 2022, 6:28:15 AM7/18/22
to str...@googlegroups.com
Hi John,

you are on the right track - I would handle this slightly differently, though.

The only thing that our UI maybe did not communicate clearly is that the "Function Query" is always treated like a scripting environment, which means that you don’t need surrounding "${ … }" for StructrScript.
For JavaScript you’d surround your code with "{ … }". Basically a single wrapping "${}" is automatically introduced.

So the easiest way would be to use a "Function Query" with "current.manyCategories".

The REST query you constructed also works.

Hope that helps!

Kai



https://structr.com
Kai Schwaiger
COO
kai.sc...@structr.com
Mobil
+49 151 / 419 811 76

Structr GmbH
Hanauer Landstraße 291
60314 Frankfurt am Main
Deutschland / Germany
Geschäftsführer: Axel Morgner
Sitz der Ges.: Frankfurt a. M.
HR: AG Frankfurt a. M. HRB 92262
Umsatzsteuer-ID: DE 279486092 




-- 
You received this message because you are subscribed to the Google Groups "structr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to structr+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/structr/7e8c752b-8301-4995-8c0c-c26b8e792a72n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages