What helper and method can be used to convert NodeName to NodeAlias?

Vasyl Chepil asked on October 6, 2021 11:03

I have custom module and class with next fields:

  • ItemName
  • ItemUrl
  • ItemDesc

On class item save I want automatically generate "ItemUrl" from "ItemName" using the same approach Kentico uses for NodeName to NodeAlias fields.

Recent Answers

Dmitry Bastron answered on October 7, 2021 08:14

Hi Vasyl,

You should be able to do so in Insert/Update Before events: in the code of event handler you can traverse your object tree and build ItemUrl from ItemNames of all parent nodes.

Note that you should use Before event which is triggered before the item gets saved into the database, so that you can easily generate ItemUrl and it will be written in the DB.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.