Rule Formatting Variable

Hello,

Is there a variable, like $SQUIDEX_URL, in the rules to get the base url of the squidex instance?

On the same part, is there a variable to get the asset type (File, Image, Video, etc)?

The squidex URL is not available. But the asset type is directly available as event.assetType.

There are also a bunch of helper functions for liquid and scripting:

  • contentUrl
  • assetContentAppUrl
  • assetContentSlugUrl

The syntax for liquid is {{event | assetContentAppUrl}} and for scripting assetContentAppUrl(event)

For the future, would you be more script or liquid for the formatting ?
Do you have any documentation on the liquid part ?
Currently, I only use the simple form for the payload of my rules…

I’ll see if contentUrl fits my need for the squidex url

Liquid is better in my opinion. The docs can be find there: https://shopify.github.io/liquid/

as much the scripts/javascript I manage, as much the liquid I have to go back to school ^^
Thanks Sebastian, I’m going to watch this

Just one thing, in liquid the access to the data is good: {{event.appId.Name}} ?
It returns empty…

PS: {{event | contentUrl}} is good :slight_smile:

{{event.appId.name}} should work

1 Like

“name” not “Name” :slight_smile:
Thanks

Just one last thing, but it’s more of a confirmation, on assets event.assetType is accessible if the trigger is Asset changed. I don’t have access to this property on a schema that has a reference to an asset? As I only need to have the asset id as reference…

In liquid you can resolve an asset with the following syntax

{% asset 'assetVariable', assetId %}

{{ assetVariable.type }}

Usually it is just “type” for asset type, but the name was not available anymore for events. Therefore the inconsistency.

Ooooh it’s really good (there little joy at the end of the day :))
I just needed the type to condition my liquid script.
Thank you very much, I will test this.

I’ll make another post for my problem of cascade rule on several schemes

1 Like

Hi,

I restructured the documentation for rule formatting options:
https://docs.squidex.io/02-documentation/developer-guides/rule-formatting

And I also added a list of all extensions:
https://docs.squidex.io/02-documentation/developer-guides/rule-formatting/liquid

1 Like