Add Administration Panel Menu Items in CS-Cart

I wrote this tutorial using CS-Cart v4.18.4.

Screenshot of the CS-Cart dashboard menu in version 18. A menu item "Get Breakfast" has been added below the last default item "Add-ons".

Template to Override

Copy this file from its location in core.

design/backend/templates/components/menu/get_primary_items.tpl

Override Location

Use a “my_changes” add-on as described in CS-Cart documentation to provide a custom version of the template.

design/backend/templates/addons/my_changes/overrides/components/menu/get_primary_items.tpl

Sample Code

This template file creates the screenshot above.

{capture name="get_items"}
    {$additional_items = [
		upload => [
			title => "Get Breakfast",
			position => 100,
			icon => 'icon-inbox',
			href => "https://breakfastco.xyz/",
			id_path => "upload",
			active => true
		]
	]}
    {* Create main menu *}
    {$navigation_home = [
        home => [
            title => __("home"),
            position => 10,
            icon => "icon-home",
            href => "index.index",
            id_path => "home",
            active => ($runtime.controller === "index" && $runtime.mode === "index")
        ]
    ]}

    {* Get additional menu items: $additional_items *}
    {include file="components/menu/get_additional_items.tpl"}

    {if $smarty.const.BLOCK_MANAGER_MODE}
        {$items = $navigation.static.central}
    {else}
        {$items = $navigation_home|array_merge:
            ($navigation.static.central|default:[])|array_merge:
            $additional_items
        }
    {/if}

    {* Get block manager data for $items and $attrs_wrapper *}
    {include file="components/menu/get_block_manager_data.tpl"}

    {$primary_items = $items scope=parent}
    {$attrs_wrapper = $attrs_wrapper scope=parent}
    {$show_collapse_default = $show_collapse_default scope=parent}
    {$main_menu_primary_class = $main_menu_primary_class scope=parent}
{/capture}