Search

@davecoggins: Thanks for explaining this.

Indeed a long time ago there has been a switch from const ROOTELEMENT to public $ROOTELEMENT when creating new events. But this has not been changed in event.section.php. Also, I have not found any upgrade path for events from Symphony 2.2, so I am really confused here.

@brendo?

Maybe I'm being dumb, but…

As this extension doesn't force the use of Symphony compatible field names, i.e. field[name], then how would I go about also storing this data in a section? Seems to me to be an obvious requirement, but it's not mentioned in the docs.

Create an event for your section as usual. The customize it.

...

public static function allowEditorToParse(){
    return false;
}

public function load(){
    if( !isset($_POST['action']['EVENT_ACTION_HERE']) ){
        return null;
    }

    // store current post data
    $post = $_POST;

    // put your own data
    $_POST['fields'] = array();

    $_POST['fields']['name']          = $post['mailchimp']['name'];
    $_POST['fields']['email']         = $post['mailchimp']['email'];
    $_POST['fields']['another-field'] = 'some other value';

    // execute as usual
    $result = $this->__trigger();

    // restore post data
    $_POST = $post;

    // return result
    return $result;
}

...

Ah I was hoping to avoid delving into manual event fiddling :) Looks straight forward enough though - thanks!

Hi guys,

Having an ajax issue (sitting lonely in the GitHub issues list).

I've included the subscribe.js file as instructed, and am calling on the function as described (having left form ID's etc intact from the exampe), and am just getting an error:

Uncaught ReferenceError: data is not defined main.min.js:2 (anonymous function)

main.min.js is my primary JS file which is where the function is called:

$('#the-form').mailchimp({
        complete: completeCallback(data),
        error: errorCallback(data) // data.error -> error message
    })

I was struggling to get it to work at all, as the URL in the subscribe.js is fixed to the root, so doesn't account for Symphony sites sat in a directory, but I've changed that manually (and the error that threw was different anyways).

Any ideas?

Just to chip in. event.section.php is the legacy event class for events generated prior to Symphony 2.3. New events generated in Symphony 2.3 use class.event.section.php instead :)

Anyone got any ideas at all about these Ajax issues? I've been looking to resolve this issue since Friday and I'm stuck on a project because of it… :(

  1. Is your javascript wrapped in a DOM-ready check?
  2. Show us your callback functions.

Hi Pat,

  1. Yup

Here's the lot:

$(document).ready(function(){
    $('#the-form').mailchimp({
        complete: completeCallback(data),
        error: errorCallback(data)
    });

    function errorCallback(data){
        console.log(data);
    };

    function completeCallback(data){
        console.log(data);
    };
});

[Edit: I've just noticed someone else with exactly the same issue in this thread: http://www.getsymphony.com/discuss/thread/32883/3/#position-53 - no marked resolution, as it seems the approach was changed - is the ajax stuff actually confirmed to work by anyone? I'm running out of user-error options, it just doesn't seem to work.]

I just took a look at assets/subscribe.js, and it looks like the data should be passing.

Try removing the (data) from your mailchimp() call. It looks to me that data is defined in the ajax function and passed to your callback. Also, I would put the callbacks before they are referenced.

$(document).ready(function(){

    function errorCallback(data){
        console.log(data);
    };

    function completeCallback(data){
        console.log(data);
    };

    $('#the-form').mailchimp({
        complete: completeCallback,
        error: errorCallback
    });

});

Hi Pat,

Function order won't be it, as even without the callbacks it still fails (at the first data reference).

I'll have to double check tomorrow, but removing the callback references doesn't fix it, as that was the first thing I tried. That shouldn't fix it anyway as clearly data should be defined. Indicates to me that nothing is being returned by the mailchimp function.

I'll try sticking the function call in a .submit() function, see if getting it to execute in the event rather than on page load makes a difference. Although can't imagine it would.

The error clearly says that data is not defined, because it isn't (at line 2). Remove this and the error should go away or turn into a different error.

But then I'd lose the success and error callbacks. That's not really a fix :p I could just as easily remove the entire function to get rid of the error, but it doesn't get me any closer to a solution. … unless you mean literally just removing the data variable, which I'll give a go.

So in summary the AJAX addition of this extension doesn't work? Or the docs are completely wrong? Can't believe it's taken a week to get this far - is there nobody out there using the ajax portion of this extension that can shed a light on why it isn't working?

Ok I've had a fiddle.

Removing the variable from the callback declaration (which is how I'd normally expect it, although I'm no JS expert - I think this is what you were suggesting, Pat) gets rid of that error. So the following:

function errorCallback(data){
        console.log(data.error);
    };
    function completeCallback(data){
        console.log(data);
    };
    $('#the-form').mailchimp({
        complete: completeCallback,
        error: errorCallback
    });

Gets me:

POST http://localhost:8888/************/symphony/extension/mailchimp/login/ 500 (Internal Server Error)

(That's the URL in subscribe.js used for the ajax call)

data.error in the errorCallback function gives me:

function (){if(l){var t=l.length;(function r(t){st.each(t,function(t,n){var i=st.type(n);"function"===i?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==i&&r(n)})})(arguments),o?s=l.length:n&&(a=t,f(n))}return this}

I've added in a console.log into the error function in the ajax request within subscribe.js - I get the same output as via my callback, just the output of that function above.

[EDIT]

After changing line 76 in subscribe.js to the full:

error: function (jqXHR, textStatus, errorThrown) {

And outputting the textStatus and errorThrown I see that it's just 'Internal Server Error', so naturally hinging on the 500 error. Which makes sense.

Could this be because I'm working off the root? I changed the url from:

url: '/symphony/extension/mailchimp/login/'

to

url: '/MYSUBDIRECTORY/symphony/extension/mailchimp/login/'

Using the default URL gives me a 404 instead of a 500.

There are no other references I see that this would cause a problem with - but maybe I'm missing something?

500 is a server error. That means the page at /symphony/extension/mailchimp/login/ has some problems. I'm not familiar with this page, so maybe someone else can enlighten what's wrong

Thanks Pat - I suspected as much. I'll have a quick look myself, see if the location is an obvious factor, as that may be referenced in the PHP.

In the meantime if anyone has any insight I'd greatly appreciate it! :)

Just adding some extra info:

I dumped the data.responseText (from the error callback in subscribe.js) and got the following:

Symphony Warning: Invalid argument supplied for foreach()
An error occurred in /Users/Nathan/httpdocs/*************/extensions/mailchimp/events/event.mailchimp.php around line 61
…

In case that sheds any light.

Seems the issue is in the event, not the ajax page (content.login.php) as I suspected. Worth noting that it all works fine without ajax, so there must be a communication issues somewhere between these files? I'm guessing the ajax function interprets things differently to the standard event?

I also need to install this plugin sometime this week, so I'll see what I get

Hey everyone,

This extension needs some love, since it has not been touched since long ago.

url: '/MYSUBDIRECTORY/symphony/extension/mailchimp/login/'

Symphony does not like to be installed in a sub directory. Try using sub domains...

Finally, be sure that you've added the proper mailchimp api key in the preference section. We manage to get it working on this site (http://ent-nts.ca/) so it should not be an extension's issue.

@nitriques

You say Symphony doesn't like being installed in a subdirectory, but I'd have to disagree. This extensions clearly doesn't like it - the 30 or so others I have installed for this project don't have an issue, neither does Symphony :)

I'd actually like to see this added as a requirement for extensions, as it;s a pain working with platforms that are fussy about location (Fork CMS, I'm looking at you).

API key etc. all input correctly. It works fine if not using the ajax.

So is the issue that it's installed in a sub directory? If so how can I make it work in a subdirectory? I'd personally consider that a bug, maybe others would disagree…

(Thanks for chiming in by the way!)

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