0 users online. Create an account or sign in to join them.Users

Search

The extension way would allow unattended removal (potentially) i.e. a CRON job for import and then the delete function triggered without interaction...

If the User is manually triggering the import while on the page.. the Ajax method would come in handy as you would get a button to trigger the removal as NIls has stated.

Look forward to seeing the results. :)

An AJAX page is just a normal backend page meant to be used for – well, you guessed it – AJAX requests. It was the easiest way for me to solve this problem, because JavaScript is something I know - that's the only reason, nothing else.

If it helps, this is the script I attached to the backend:

(function($) {

    $(document).on('ready', function() {
        var env = Symphony.Context.get('env');

        if(env.section_handle == 'produkte') {
            $('#context .actions').append(
                '<li><a class="button import">CSV-Import</a></li>'
            ).on('click', '.import', function(event) {
                var notifier = $('div.notifier'),
                    entries = $('table').animate({
                        opacity: 0.2
                    }, 'fast'),
                    spinner = $('<div />', {
                        class: 'spinner'
                    }).appendTo('#contents');

                $.ajax({
                    url: Symphony.Context.get('root') + '/symphony/extension/my_extension/import/',
                    dataType: 'json',
                    timeout: 60000,
                    cache: false,

                    error: function(a, b, c) {
                        notifier.trigger('attach.notify', ['Leider ist beim Import ein Fehler aufgetreten.', 'error']);
                        spinner.remove();
                        entries.css('opacity', 1);
                    },

                    success: function(result) {
                        notifier.trigger('attach.notify', [result.message, result.status]);
                        $.ajax({
                            url: window.location.href,
                            dataType: 'html',
                            success: function(result) {
                                var html = $(result),
                                    body = html.find('table tbody');

                                entries.find('tbody').replaceWith(body);
                                spinner.remove();
                                entries.css('opacity', 1);
                            }
                        });
                    }
                });
            });
        }
    });

})(window.jQuery);

@Nils - how did you attach this AJAX to the backend? I have been looking for a way to remove items that have been imported that are no longer on the list that I'm importing.

@ijy, or anyone else who has come across this. I have a similar sort of set up to the ones mentioned above i.e. I have a section that is populated by xml importer on a daily basis. I am looking to delete/archive the entries that haven't been modified each day so they no longer appear on the front end of the site.

I am having trouble setting this up though...I am new to extensions and would really like to learn but at the moment I don't know the best place to start. Did you get your 'delete removed entries' extension working? If so could you please point me in the right direction as to go about doing this myself. I'm just going around in circles at the moment!

Does this help? The idea is to capture the datetime each time an entry is added or updated, and then filter out any >24 hours old. I haven't tried it myself, but in theory…

Auto deleting entries based on external reference (using XML Importer)

That's great @briandrum, thank you for the suggestion, after reading it through several times I got my head around it and got it working. Thanks again

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details