Q&A: I need to sort the portals entries with many categories - what’s the correct syntax?

Question

I need to sort the portals entries and bring the items for multiple categories in the desired order. Doing this via the UMC works, but I need a CLI version with udm - what’s the correct syntax?

Answer

The syntax for setting the portals entries has changed to the content attribute (portalEntriesOrder is deprecated since Aug. 2018) and for the value a JSON object is needed to have the desired order. An example:

eval "$(ucr shell ldap/base)"
json_content=$(cat << END
  [
    [
      "cn=service,cn=categories,cn=portal,cn=univention,${ldap_base}",
      [
        "cn=teacherconsole,cn=portal,cn=univention,${ldap_base}",
        "cn=horde,cn=portal,cn=univention,${ldap_base}"
      ]
    ],
    [
      "cn=admin,cn=categories,cn=portal,cn=univention,${ldap_base}",
      [
        "cn=umc-domain,cn=portal,cn=univention,${ldap_base}",
        "cn=nagios,cn=portal,cn=univention,${ldap_base}",
        "cn=backupserver,cn=portal,cn=univention,${ldap_base}"
      ]
    ]
  ]
END
)
udm settings/portal modify \
     --dn "cn=domain,cn=portal,cn=univention,${ldap_base}" \
     --set content="${json_content}"

Please note: The value of content has to be a valid JSON Object. You can check the syntax i.e. with https://www.jslint.com/

1 Like