engine.PublishingContext.ResolvedItem.Item.Id
You can also check the permitted Publishing Context element and see if it is a page or not (if it is not, then it is a component).
For instance:
Item currentItem;
if (engine.PublishingContext.ResolvedItem.Item is Page)
{
currentItem = package.GetByName(Package.PageName);
}
else
{
currentItem = package.GetByName(Package.ComponentName);
}
TcmUri currentId = engine.GetObject(currentItem).Id;
If you want to shorten the call to engine.GetObject (), you can directly get the identifier from the XML element:
String currentId = currentItem.GetAsSource().GetValue("ID");
source
share