Show Posts


Topics - dhigz

Pages: [1] 2
1
Templates / Bootstrap5 and Three Columns
« on: September 09, 2023, 04:00:46 PM »
I recently upgraded a site to AbanteCart 1.3.4 and using the Bootstrap5 template. No matter what I do, I cannot get the page to work with three columns. Using either column left or column right work fine but both destroys the layout.

What happens: When using three columns, the columns stack instead of being displayed inline.

I have tried several different combinations of flex utilities with some success but nothing works consistently.

I would really like to use a three column layout. Any thoughts? Suggestions?

2
AbanteCart v2.0 / Suggested Changes to task_api.php
« on: December 14, 2020, 11:29:22 PM »
After some extensive testing, I have found some issues with task_api.php that should be looked at.

1) Running a task from task_api cron causes an error which can be found in the error log:

Code: [Select]
warning: AbanteCart core v.1.2.16 Use of undefined constant RDIR_TEMPLATE - assumed 'RDIR_TEMPLATE' (this will throw an Error in a future version of PHP) in <b>[path to file]/httpdocs/core/engine/view.php</b> on line <b>93</b>
The error has to do with the declaration of the template directory. The simple solution is to add a declaration to task_api.php as it is in task.php:

Code: [Select]
define('RDIR_TEMPLATE', 'admin/view/default/');

2) The command "--force" is negated when running a task. Take a look at the function processTask().

Code: [Select]
function processTask($options)
{
    $tm_mode = 'cli';
    $tm = new ATaskManager($tm_mode);
    if ($options['force']) {
        echo "Force starting task! \n";
        if (
            !$tm->updateTask($options['task_id'], array('status' => $tm::STATUS_READY))
            || !($steps = $tm->getTaskSteps($options['task_id']))
        ) {
            echo "Error: Task ID {$options['task_id']} can not be re-started! \n";
            exit(1);
        }

        foreach ($steps as $step) {
            $tm->updateStep($step['step_id'], array('status' => $tm::STATUS_READY));
        }
    }

    echo "Running: Task ID {$options['task_id']}: \n";
    if (!$tm->runTask($options['task_id'])) {
        //error
        echo "Error: Task ID ".$options['task_id']." has failed! \n";
    }
    if ($options['show_log']) {
        $run_log = $tm->getRunLog();
        $run_log_text = implode("\n", $run_log);
        echo "{$run_log_text}\n";
    }
    echo "Finished running: Task ID ".$options['task_id'].": \n";
}

If option['force'] etc works as it should. the status values are reset to 1 or STATUS_READY as it should. However, when $tm->runTask is run later in the function, if successful, the status values are set to 5 or STATUS_COMPLETED. STATUS_FAILED if not.

The simple fix is to move the "force" section after the runTask section and before the log section, like:

Code: [Select]
function processTask($options)
{
    $tm_mode = 'cli';
    $tm = new ATaskManager($tm_mode);
    echo "Running: Task ID {$options['task_id']}: \n";
    if (!$tm->runTask($options['task_id'])) {
        //error
        echo "Error: Task ID ".$options['task_id']." has failed! \n";
    }
if ($options['force']) {
        echo "Force starting task! \n";
        if (
            !$tm->updateTask($options['task_id'], array('status' => $tm::STATUS_READY))
            || !($steps = $tm->getTaskSteps($options['task_id']))
        ) {
            echo "Error: Task ID {$options['task_id']} can not be re-started! \n";
            exit(1);
        }

        foreach ($steps as $step) {
            $tm->updateStep($step['step_id'], array('status' => $tm::STATUS_READY));
        }
    }
    if ($options['show_log']) {
        $run_log = $tm->getRunLog();
        $run_log_text = implode("\n", $run_log);
        echo "{$run_log_text}\n";
    }
    echo "Finished running: Task ID ".$options['task_id'].": \n";
}

3. There is no way to use the force option to run all tasks. There are no provisions in the task_api file. There are a couple of ways this can be fixed but involves changing both the task_cli file as well as the core/task_manager file. Regardless it would be a nice option to have.



3
How-to questions / Task.php, Task API Key and tsk Documentation
« on: December 05, 2020, 10:44:01 PM »
OK,

I have a task set up. It works perfectly when run from the Schedule Tasks screen. It also works perfectly when run from the browser when adding ?task_api_key=[my key] to the url. What I cannot get to work is running the task.php from CRON.

Following the examples on CRON in the documentation: https://abantecart.atlassian.net/wiki/spaces/AD/pages/15007901/Scheduled+Tasks#ScheduledTasks-CRON for my Plesk server CRON will run the Task.php script but I get a response of: "Authorize the Access".

Looking at the task.php code it is clear this message is coming from the following:
Code: [Select]
// add to settings API et task_api_key
$task_api_key = $config->get('task_api_key');
if (!$task_api_key || $task_api_key != (string)$_GET['task_api_key']) {
    exit('Authorize to access.');
}

What is clear is that running the command in CRON per the documentation does not work and to get it to work requires the task_api_key to be sent. However, there is no mention or explanation on how to do this.

My attempts at different methods to send the key have all failed. I attempted adding parameters to the file name gave a could not open file error. Passing the key value pair as an argument open the file but gave me the "Authorize the Access" error.

The only way I can successfully run the task.php file from CRON is to remove the $_GET requirement from the is statement.

What does work and I am doing for now is to direct CRON to the task_cli.php file instead. Problem is there is no API Key security. Using task_cli.php is not even mentioned on this documentation page. 

My point of this post is that something needs to be fixed so others do not have their time wasted as mine was today.
  • Tell me how to pass the task api parameter for I can use task.php.
  • Fix task.php so it recognizes an argument value and not just $_GET.
  • Fix the documentation.

I am ready to release a new extension and this is the only thing holding me up. I do not want to mislead people by sending them to misleading documentation. If there is an answer to #1, I would sure like to know it.

Thanks


4
How-to questions / Task Manager Configuration
« on: November 01, 2020, 03:33:56 PM »
Hi,

Working on a new extension that requires the creation and execution of two tasks. This is the first time I have created a task and I understand the idea is to call the task.php file by way of Crontab which will then run all of the tasks in the tasks in the tasks table. My question concerns the frequency of each task.

One of my new tasks need to run every hour while the other needs to run once a day. Reading the documentation and looking at the existing tasks, there are no examples of setting different run times. I do see the 'run_interval' value in the addTask array but this is described as "interval in seconds since last run" in the documentation.

How do you suggest I solve my problem with two tasks to be run at different run times?

Don

5
Built-in Features / Resouce Library Modal Icon images
« on: September 13, 2020, 04:08:49 PM »
I am a  long term user of AbanteCart. It has always annoyed me that all icons how in the Resource Library Modal with the fa-code icon instead of the actual icon. Since my the issue has been corrected in the Media Manager and icons show as they truly are and my level of frustration reached a peak, I decided to fix the problem. Little did I know how easy it was.

A small edit to /admin/view/default/template/responses/common/resource_library.tpl is all it took.

On line 184 find:
Code: [Select]
<?php if ($rl['resource_code']) { ?>
<div class="thmb-prev thmb-icon">
<i class="fa fa-code fa-3"></i>
        </div>
<?php } else { ?>

Change it to:

Code: [Select]
<?php if ($rl['resource_code']) { ?>
<div class="thmb-prev thmb-icon">
<?php echo $rl['resource_code']; ?>
         </div>
<?php } else { ?>

Please consider making this change in future releases.


6
Extensions and Add-Ons / Loading resource scripts in hook function
« on: September 03, 2020, 09:09:24 PM »
Hi,

I am attempting to add image functionality to and existing controller by loading the resource_scripts though dispatch and dispatchGetOutput like other controllers. I can add the html using addChild with no problem. The script portion is throwing an error: Call to protected method AController::dispatch() from context '...

Here is the code which is included in function onController...._UpdateData().
Code: [Select]
$resources_scripts = $that->dispatch(
            'responses/common/resource_library/get_resources_scripts',
            array(
                'object_name' => 'collections',
                'object_id'   => $id,
                'types'       => array('image'),
            )
        );
        $that->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput());


Any suggestions of how I can get around this error or a different method to add the resource scripts?

Don

7
Extensions and Add-Ons / Best place to hook for a completed order?
« on: July 16, 2020, 08:22:27 PM »
Hi,

What is the best controller and method to hook to in order to capture a successfully completed order with payment made. Is ControllerPagesCheckoutSuccess the best controller? Or do you recommend another controller/method?

I do see the value for $this->session->data['processed_order_id'] is created after validation. Are there any other indicators of a successful order?

Thanks.

8
There is an inherent problem in AbanteCart with having more than one tinymce editor loaded on a single page. I have an extension where I need to have multiple instances of tinymce loaded. There may be other developers with the same issue.

In the admin/view/template/form/text_editor.tpl file which loads the instance tinymce for each texteditor form field type, the first command in the javascript portion is to remove all existing instances of tinymce on the page. This is correct in the creation of the custom tinymce editor used in AbanteCart. However, when the second instance is added it also removes the first, third removes the first and second, etc. While the editor looks and works right for the HTML/Text portion, the Visual portion will only work on the last instance added.

The solution is to remove the specific instance being loaded. Instead of tinymce.remove(), replace with tinymce.remove('textarea#text_editor_<?php echo $id ?>').

Now all instances of tinymce will work correctly. Please make this change in the next release.

9
I am working on an extension that uses the new "Quick View" option. Everything is working great but I need to filter out a description field in quick view mode. The problem is I cannot get the viewport_mode value in func_get_args() in my hook function. The hook function does process  func_get_args() and I can get other value pairs, just not the viewport_mode/value pair.

I tried calling func_get_args() an InitData hook for the page, but get same result (or lack there of). Same result if called in an UpdateData hook.

The only way I could get it to work is to add $this->data['viewport_mode'] = $viewport_mode; to the base file.

Do you have any suggestions on what I can do so I do not have to edit the base file?

Thanks

10
Extensions and Add-Ons / How to get and return data to Listing_Grid Hook
« on: September 08, 2016, 07:37:09 PM »
Hi,

What I am trying to is to add an additional drop down to the product search/filer form on the catalog/products page. No problem adding the field to the form through a hook. The problem is getting and returning data to the listing_grid controller with any form of hook (on, before, etc. & InitData, ProcessData, etc.)

With a standard controller, you can get data from the controller with $that->view->getData when the controller data is in the form of $this->data, $this->post, etc.. You can transfer data from the hook to the controller with $that->view->assign or $that->view->batchAssign($this->data). You can even resort to sessions.

Keeping in mind that we do not want to unnecessarily edit the base controller file, how do you transfer data back and forth with a listing_grid controller? Specifically how would I get filter data in and/or the response back? I could not find anything in the Developer guide that helps.

What have I tried?
1 - With the original goal I tried to add the new field value to the filter value with onControllerResponsesListingGridProduct_InitData and onControllerResponsesListingGridProduct_UpdateData. This is useless as anything you submit is overwritten in the function.

2 - Rewrote the entire ControllerResponsesListingGridProduct under onControllerResponsesListingGridProduct_UpdateData starting off by setting the original response to an empty array. The final command of the hook function is to set the output. I also created another query with parameters added for my filter data and call this query in the hook function.

Now what happens is both run, first the original then the hook. Tried using InitData, same result just the hook runs first then the base function. No matter which option, the output is still the result of the base controller function.

3 - Tried  aroundControllerResponsesListingGridProduct_InitData. Around does not work.

The only way I got it to work is commenting out  $this->load->library('json'); and $this->response->setOutput(AJson::encode($response)); in the base controller. Exactly what I want to avoid.


Any suggestions, ideas?




11

There is a small formatting issue on order confirm mail template (template/mail/order_confirm.tpl). It has existed on the first version I downloaded (1.1.9) and still exists today.

While it does not detract in any way to this wonderful shipping cart application, it is visible to every one of our customers. I fix it every time I upgrade, so I thought it worth mentioning and maybe it can get fixed.

If you look at the order confirmation email the customer gets, the top of the Model column does not align with the rest of the row. This is because it does not have the same style settings as the rest of the rows. Simple fix: add width: 15%; padding: 0.3em; to the style attribute to match the other columns.

Good to go.

Don

12
No matter what I do I cannot get the aroundClassNameMethodName_InitData function to work in my hooks file. Everything else (on, before, etc.) works fine.

What I am attempting to do is to replace the main function on storefront/pages/checkout/confirm.php with my own function and stop the native function from running. Using around will not allow my function to run but the native function still does. Using any other extension hook for InitData, my function will run but will still allow the native function to run. I can't use update data because the "damage is already done". In other words the order gets saved, exactly what I am trying to stop.

What I really want to do is is stop the existing "save order" function call in and replace it with a "save order" function of my own. I have specific requirements that do not work with the existing order core file.

I have tried replacing the entire confirm.php file with my own by placing my version in my extensions storefront/pages/checkout directory and adding the path in my extensions main.php file, but apparently this does not work as the controller will not be overridden. (interesting result though, when you remove the native controller file, it does use the extension controller file).

So I have two possible solutions and neither work. 1) use the extension hook "around" or 2) get the extension controller file to override the native file.

Any thought, ideas?

Don

13
I am using the hook onXxxxx_UpdateData in my extension core file to add a form field to an existing form. I don't want to just put it at the end but rather in a logical place within the form.

Is there a way to insert a form field after an existing form field? Any trick hidden functions I can use?

Open to suggestions.

Don

14
General Discussion / Have you ever output a $form array?
« on: August 02, 2016, 01:40:40 AM »
Have you ever output a form array? (print_r(array_values($form))) I did. It's huge as every element has the entire registry in the array.

If you want to try it, be careful as it will eat up your memory. Make a form with one form element just to see.

So AbanteCart gurus, can you tell me why every form element includes the entire registry as one of it's array values? There must be some valid reason to have all of this overhead every time you output a form.

Don

15
General Extensions / Multiple instances of timymce on admin pages
« on: July 26, 2016, 12:11:02 AM »
When placing more than one "texteditor" (aka tinymce instance) type form field on an admin side form, only the last tinymce instance works properly.

Any instances placed before the last one have these problems: 1) When switching to visual mode, the text area looses all formatting and buttons. Switching back shows correct HTML/Text View. 2) The field acts as an updateable field (ie. turns orange).

I took a look at the jquery code in the form/text_area.tpl file. First thing I noticed was 'tinymce.remove();' was at the very top which appears that the second instance would kill the first instance, but removing it had no affect one way of the other.

One thing I did find is that the value for 'activeEditor' was the last tinymce instance when you clicked on the first. This would suggest to me that activeEditor should be defined. I tried a few solutions, but could not get any to work properly.

Does anyone have a fix for this or a suggestion of how to proceed? The extension I am working on really needs multiple instances of tinymce on the page. This problem appears to be one of the downsides of switching from ckeditor.

Don


Pages: [1] 2

Powered by SMFPacks Social Login Mod