Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storefront Link to Admin to Edit an Item #3480

Open
bhsmither opened this issue Jan 27, 2024 · 2 comments
Open

Storefront Link to Admin to Edit an Item #3480

bhsmither opened this issue Jan 27, 2024 · 2 comments

Comments

@bhsmither
Copy link
Contributor

bhsmither commented Jan 27, 2024

Now with a hook in GUI->addBreadcrumb(), this can be done, but it would be nice to have this anyway.

Feature Request:
This adds an icon after every crumb, which is a link to the edit page of that item.

Find in GUI-addBreadcrumb():
        if (!empty($name)) {
            $this->_breadcrumb[] = array(
                'url' => $GLOBALS['seo']->SEOable($href),
                'title' => ucfirst(strip_tags(str_replace('_', ' ', $name)))

Change to:
        preg_match('@\?_a\=(product|category|document)\&(amp;)?(product_id|prod_id|cat_id|doc_id)\=([\d]+)@',$href,$hrefmatch);
        switch ($hrefmatch[1] ?? false) {
            case 'product': $return = '/'.$GLOBALS['config']->get('config', 'adminFile').'?_g=products&node=index&action=edit&product_id='.$hrefmatch[4]; break;
            case 'category': $return = '/'.$GLOBALS['config']->get('config', 'adminFile').'?_g=categories&node=index&action=edit&cat_id='.$hrefmatch[4]; break;
            case 'document': $return = '/'.$GLOBALS['config']->get('config', 'adminFile').'?_g=documents&node=index&action=edit&doc_id='.$hrefmatch[4]; break;
            case false: $return = false;
        }
        if ($GLOBALS['session']->get('super_user', 'admin_data')) {
            $GLOBALS['smarty']->assign('HOMECRUMB'
            , '/'. $GLOBALS['config']->get('config', 'adminFile')
            . '?_g=documents&node=index&action=edit&doc_id='
            . $GLOBALS['db']->select('CubeCart_documents','doc_id','doc_home=1')[0]['doc_id']);
        }
        if (!empty($name)) {
            $this->_breadcrumb[] = array(
                'admin' => ($return && $GLOBALS['session']->get('super_user', 'admin_data') ? $return : false),
                'url' => $GLOBALS['seo']->SEOable($href),
                'title' => ucfirst(strip_tags(str_replace('_', ' ', $name)))

Find in Catalogue->displayProduct():
                $GLOBALS['gui']->addBreadcrumb($product['name'], currentPage());

Change to:
                $GLOBALS['gui']->addBreadcrumb($product['name'], '?_a=product&product_id='.$product['product_id']); // currentPage());

Find in CubeCart->loadPage():
                        $GLOBALS['gui']->addBreadcrumb($document['doc_name'], currentPage());

Change to:
                        $GLOBALS['gui']->addBreadcrumb($document['doc_name'], '?_a=document&doc_id='.$document['doc_id']); // currentPage());

Find in the Foundation template element.breadcrumb.php:
            <span class="show-for-medium-up" itemprop="name">{$LANG.common.home}</span>
         </a>

Change to:
            <span class="show-for-medium-up" itemprop="name">{$LANG.common.home}</span>
         </a>{if $HOMECRUMB}<a href="{$HOMECRUMB}" target="_blank"><svg class="icon"><use xlink:href="#icon-search"></use></svg></a>{/if}

Also find:
            <span itemprop="name">{$crumb.title}</span>
         </a>

Change to:
            <span itemprop="name">{$crumb.title}</span>
         </a>{if $crumb.admin}<a href="{$crumb.admin}" target="_blank"><svg class="icon"><use xlink:href="#icon-search"></use></svg></a>{/if}

Add these CSS rules somewhere:
a[target] {
  color: red;
  font-weight: bold; }
a[target]:hover {
  text-decoration: none; }

It would be better to use an 'edit' SVG graphic instead of the 'search' SVG graphic. But there isn't one.

@abrookbanks
Copy link
Member

abrookbanks commented Jan 29, 2024

I like this but I personally don't like it being inline in the page. Maybe like the (store offline) notification there could be a navigation bar at the top instead to edit the current page. Or maybe three choices.

  • Off
  • On (inline)
  • On (in navigation bar)

@bhsmither
Copy link
Contributor Author

A single link to "edit the current page". I can work with that - having to view the actual category page to get at the link to edit that category.

@abrookbanks abrookbanks modified the milestone: 6.5.4 Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants