2018-10-29 12:27 PM - last edited on 2022-10-05 01:33 PM by Daniel Kassai
item.itemType = API_StoryNavItem; item.mapId = API_PublicViewMap; err = ACAPI_Environment (APIEnv_SearchNavigatorItemID, &item, &items, NULL);But i tried to change parameters to get layouts like below, and i'm getting this error:
APIERR_BADDATABASE -2130313110.
item.itemType = API_LayoutNavItem; item.mapId = API_LayoutMap; err = ACAPI_Environment (APIEnv_SearchNavigatorItemID, &item, &items, NULL);From that error i tried to assign database info to the search query. with this.
API_DatabaseInfo db; BNZeroMemory (&db, sizeof (API_DatabaseInfo)); db.typeID = APIWind_LayoutID; item.itemType = API_LayoutNavItem; item.mapId = API_LayoutMap; item.db =db; err = ACAPI_Environment (APIEnv_SearchNavigatorItemID, &item, &items, NULL);And this way i got the same result... database error.
err=ACAPI_Database (APIDb_ChangeCurrentDatabaseID,&db);And this gave me the same database error. After that i don't have aní clue to solve my issue.
Solved! Go to Solution.
2018-11-15 11:35 AM
GS::Array<API_NavigatorItem> GetNavItemChildren (const API_NavigatorItem& item) { API_NavigatorItem** children = nullptr; err = ACAPI_Environment (APIEnv_GetNavigatorChildrenItemsID, &item, &children); if (err != NoError) return err; const Int32 childCount = BMhGetSize ((GSHandle)children) / Sizeof32 (API_NavigatorItem); GS::Array<API_NavigatorItem> childArray; for (Int32 ii = 0; ii < childCount; ++ii) { const API_NavigatorItem& childItem = (*children)[ii]; childArray.Push (childItem); childArray.Append (GetNavItemChildren (childItem)); } BMhKill ((GSHandle *)&children); return childArray; } GS::Array<API_NavigatorItem> GetAllLayoutNavItem () { API_NavigatorSet set; BNZeroMemory (&set, sizeof (API_NavigatorSet)); set.mapId = API_LayoutMap; GSErrCode err = ACAPI_Environment (APIEnv_GetNavigatorSetID, &set); if (err != NoError) return err; API_NavigatorItem rootItem; BNZeroMemory (&rootItem, sizeof (API_NavigatorItem)); rootItem.guid = set.rootGuid; rootItem.mapId = set.mapId; return GetNavItemChildren (rootItem); }
2018-11-15 11:35 AM
GS::Array<API_NavigatorItem> GetNavItemChildren (const API_NavigatorItem& item) { API_NavigatorItem** children = nullptr; err = ACAPI_Environment (APIEnv_GetNavigatorChildrenItemsID, &item, &children); if (err != NoError) return err; const Int32 childCount = BMhGetSize ((GSHandle)children) / Sizeof32 (API_NavigatorItem); GS::Array<API_NavigatorItem> childArray; for (Int32 ii = 0; ii < childCount; ++ii) { const API_NavigatorItem& childItem = (*children)[ii]; childArray.Push (childItem); childArray.Append (GetNavItemChildren (childItem)); } BMhKill ((GSHandle *)&children); return childArray; } GS::Array<API_NavigatorItem> GetAllLayoutNavItem () { API_NavigatorSet set; BNZeroMemory (&set, sizeof (API_NavigatorSet)); set.mapId = API_LayoutMap; GSErrCode err = ACAPI_Environment (APIEnv_GetNavigatorSetID, &set); if (err != NoError) return err; API_NavigatorItem rootItem; BNZeroMemory (&rootItem, sizeof (API_NavigatorItem)); rootItem.guid = set.rootGuid; rootItem.mapId = set.mapId; return GetNavItemChildren (rootItem); }
2019-05-01 10:00 AM
Tibor wrote:I'm playing around with Navigator. Since it was moved to separate class form Environment. I have updated code. However, it doesn't seem to work in any case. There is a slight success with Publisher Set. I can access set but I can't access any child. In the case of other types, I got nothing. Please help.
But you can iterate through the layout tree using APIEnv_GetNavigatorSetID and APIEnv_GetNavigatorChildrenItemsID methods:
GS::Array<API_NavigatorItem> GetNavItemChildren(const API_NavigatorItem* item) { ACAPI_WriteReport("child", true); API_NavigatorItem** children = nullptr; //GS::ErrCode err = ACAPI_Environment(APIEnv_GetNavigatorChildrenItemsID, &item, &children); //API_NavigatorItem* = &item; GS::ErrCode err = ACAPI_Navigator(APINavigator_GetNavigatorChildrenItemsID, &item, &children); err; ACAPI_WriteReport(GS::ValueToString(err), true); //if (err != NoError) // return err; const Int32 childCount = BMhGetSize((GSHandle)children) / Sizeof32(API_NavigatorItem); GS::Array<API_NavigatorItem> childArray; ACAPI_WriteReport("cnt", true); ACAPI_WriteReport(GS::ValueToString(childCount), true); for (Int32 ii = 0; ii < childCount; ++ii) { const API_NavigatorItem& childItem = (*children)[ii]; ACAPI_WriteReport(childItem.name, true); childArray.Push(childItem); childArray.Append(GetNavItemChildren(&childItem)); } BMhKill((GSHandle *)&children); return childArray; } void GetAllLayoutNavItem() { ACAPI_WriteReport("set", true); API_NavigatorSet set; BNZeroMemory(&set, sizeof(API_NavigatorSet)); //set.mapId = API_PublicViewMap; set.mapId = API_LayoutMap; //set.mapId = API_PublisherSets; int idx = 1; //for Publisher Set idx; GSErrCode err = ACAPI_Navigator(APINavigator_GetNavigatorSetID, &set); //if (err != NoError) // return err; ACAPI_WriteReport(GS::ValueToString(err), true); const Int32 setCnr = BMhGetSize((GSHandle)&set) / Sizeof32(API_NavigatorSet); ACAPI_WriteReport(GS::ValueToString(setCnr), true); err; API_NavigatorItem rootItem; BNZeroMemory(&rootItem, sizeof(API_NavigatorItem)); rootItem.guid = set.rootGuid; rootItem.mapId = set.mapId; ACAPI_WriteReport(set.name, true); ACAPI_WriteReport(GS::ValueToString(set.mapId), true); GetNavItemChildren(&rootItem); }
2019-05-14 01:59 PM
2019-07-18 01:34 PM
kzaremba wrote:Can you post the final code which you have iterated layouts successfully with?
After a few hours of debugging, I found a solution. Code works. I passed GUID of Navi Set... Which seem quite logical. But as it turned out it should be rootGuid. Does anyone know the difference?
2019-07-22 03:35 PM
Tomer1 wrote:Hi, as far as I remember this piece of code should work. Later on, I was just referring to GUID o set instead of rootGUID. Let me know if it's wroking.
Can you post the final code which you have iterated layouts successfully with?
2019-07-23 04:52 PM
2019-07-23 05:21 PM
2019-07-23 07:55 PM
2019-07-24 12:17 PM