Child pages
  • [cms] The "AdminEditButton" tag doesn't respect sub-items [5.2.2-B1]
Skip to end of metadata
Go to start of metadata

The "AdminEditButton" tag creates green "Edit Item" button on CMS pages, that once clicked will lead directly to an item editing page in Admin Console. It is pretty handy, because you don't need to leave page you're currently editing.

Unfortunately, when dealing with sub-items (e.g. images of a category, prices of product, etc.) the opened page is broken.

Solution

When building link in "AdminEditButton" tag and used prefix is sub-item of someone, then include these in built link:

  • parent item id (taken from foreign key field if current item, so no extra SQLs)
  • add parent item prefix to "pass" parameter

Related Tasks

INP-1590 - Getting issue details... STATUS

1 Comment

  1. I've also found this, while creating a patch:

    • when you attempt to use sub-item prefix (e.g. during content block editing) the "{prefix}_mode" parameter is being set to sub-item prefix, e.g. "content_mode" and since "content" unit doesn't have "mode" parameter the "OnEdit" event doesn't use temp table
    • the "std_edit_item" function is used to open editing window regardless of you need temp mode or not
    • when you manage to open editing of sub-item in temp mode the saving part calls sub-item's "OnUpdate" (saves data to temp table) without following parent's "OnSave" event and data never leaves temp table

    Here are the solutions so far:

    when you attempt to use sub-item prefix (e.g. during content block editing) the "{prefix}_mode" parameter is being set to sub-item prefix, e.g. "content_mode" and since "content" unit doesn't have "mode" parameter the "OnEdit" event doesn't use temp table 

    Always pass parent item id and set "mode" parameter on parent.

    the "std_edit_item" function is used to open editing window regardless of you need temp mode or not

    Use "std_edit_item" function, when temp mode is needed and "std_edit_temp_item" when it's not needed.

    when you manage to open editing of sub-item in temp mode the saving part calls sub-item's "OnUpdate" (saves data to temp table) without following parent's "OnSave" event and data never leaves temp table

    Solved by calling parent unit "OnSave" event from sub-item "OnUpdate" event when "admin=1" found in URL and we're in temp mode.