Jump to content

Admin Inline Edit


Claudia M

Recommended Posts

  • Replies 51
  • Created
  • Last Reply

The skin edit isn't easily coded into a code snippet, so keep in mind that an upgrade will overwrite it.

In the admin skin template products.index.php, near line 78, find:

<td>{$product.product_code}</td>

Change to:

<td><span class="editable number" name="product[{$product.product_id}][product_code]">{$product.product_code}</span></td>

The core code edit can be put in a code snippet, but for the purpose of testing this and determining if it works for you, this will be an edit to the core code.

In the admin source code products.index.inc.php, near line 627, find:

foreach ($GLOBALS['hooks']->load('admin.product.pre_display') as $hook) {
    include $hook;
}

After that, add this:

if (isset($_POST['product']) && is_array($_POST['product']) && Admin::getInstance()->permissions('products', CC_PERM_EDIT)) {
    // Update Product Code
    foreach ($_POST['product'] as $product_id => $product_code) {
        $GLOBALS['db']->update('CubeCart_inventory', array('product_code' => $product_code), array('product_id' => $product_id));
    }
    httpredir(currentPage());
}

When the mouse cursor hovers over the Product Code value, there should be a 'tooltip' that says "Click to Edit". When clicked on, the table cell should change to show a text entry field. Make your changes to the value(s). Click Save.

The new value(s) should now be in use.

Link to comment
Share on other sites

Thanks Brian I'll implement it asap.  I don't mind having to change the skin/product.index ... I have to do it for other stuff anyway.

I implemented the code, cleared the cache, and made a change to a product code.  It let me change it but when I click on save the change isn't saved even after I clear the cache again.

Link to comment
Share on other sites

Can I do something like this in the skin/product.index file without deleting all my current product codes?

<td align="center"><input type="text" name="product[{$product.product_id}]" id="product_code_{$product.product_id}" value="{$product.code}" class="textbox" style="width: 50px;" /></td>

Link to comment
Share on other sites

The code is first dealing with surveying the Status checkboxes - which are always POSTed. After updating the status of each of the products, the code tells the web browser to reload the page. Thus, surveying POST for any updates to the Product Code, never happens.

Since the status codes are always surveyed, we should put the new code inside that. So...

Remove the added code from products.index.inc.php.

Find near line 489:

if (isset($_POST['status']) && is_array($_POST['status']) && Admin::getInstance()->permissions('products', CC_PERM_EDIT)) {
    // Update Status
    foreach ($_POST['status'] as $product_id => $status) {
        $GLOBALS['db']->update('CubeCart_inventory', array('status' => $status), array('product_id' => $product_id));
    }
    httpredir(currentPage());
}

Change to:

if (isset($_POST['status']) && is_array($_POST['status']) && Admin::getInstance()->permissions('products', CC_PERM_EDIT)) {
    // Update Status
    foreach ($_POST['status'] as $product_id => $status) {
        $GLOBALS['db']->update('CubeCart_inventory', array('status' => $status), array('product_id' => $product_id));
    }

    if (isset($_POST['product']) && is_array($_POST['product'])) {
    // Update Product Code
        foreach ($_POST['product'] as $product_id => $product_code) {
            $GLOBALS['db']->update('CubeCart_inventory', array('product_code' => $product_code['product_code']), array('product_id' => $product_id));
        }
    }

    httpredir(currentPage());
}

The nice thing about this "click to edit" is that there is only a database query to UPDATE only those values that changed. To make them a permanent text entry field, then there will be an UPDATE query made for each of the twenty list items.

And it won't change the problem just now faced (bouncing after dealing with the Status setting).

Practically speaking, there is a better way of processing a POST from the main list.

Link to comment
Share on other sites

Hello, here is the error message I got

 

[<strong>Exception</strong>] /home/santonsp/www/boutique/santons-de-provence/peyron-campagna/includes/lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php:619 - Syntax error in template "file:/home/santonsp/www/boutique/santons-de-provence/peyron-campagna/admin_xDG7xw/skins/default/templates/products.index.php" on line 619 "" unclosed {if} tag

Link to comment
Share on other sites

Must be a different problem. For this project, the edits to the skin template was up around line 78 and did not involve an {if} statement.

Please post here line 619, along with the few lines above and the few lines following.

Link to comment
Share on other sites

If the image above is correct, and there are no more lines beyond line 617, then a good chunk of the file has been deleted. That file actually has 719 lines of code.

You must have recently replaced it with a fresh copy before I got to download it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.




×
×
  • Create New...