Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

onAfterWrite javascript Parse Error

Go to End

6 Posts   1917 Views


Community Member, 254 Posts

19 February 2010 at 5:40pm

Hey All :)
Any one else have a similar problem?
I've included a Twitter class in Page, for auto tweeting after writing data.

Goes like
public function onAfterWrite()
$t = new Twitter('****','****');

Everything still works fine, data is saved and tweet is sent.
But I get two errors in base.js promoting me that errors occurred and it didn't go according to plan.

From fire fox web tools plugin error console .
"reference to undefined property jQuery.cache[id][name]"
jQuery.cache[id][name]=data;return name?jQuery.cache[id][name]:id;},removeData:function(elem,name){elem=elem==window?windowData:elem;var id=elem[expando];if(name){if(jQuery.cache[id]){delete jQuery.cache[id][name];name="";for(name in jQuery.cache[id])


"reference to undefined property window.opera"

Its probably a difficult thing to answer as it's an issue with my twitter class. Remove the twitter code and all works a charm. Just wondering if anyone had any pointers?


Community Member, 904 Posts

19 February 2010 at 8:10pm

What twitter class did you use?
Maybe try this one instead:

Btw. you could also use AbsoluteLink instead of yourdomain + Link. Eg.

$t->updateStatus($this->Title . ' ' . $this->AbsoluteLink()); 


Community Member, 254 Posts

23 February 2010 at 1:51pm

Thanks for the reply banal. I was trying to find the AbsoluteLink, I remember seeing it a 6 months ago but couldn't remember.

I'm using Twitter class by Tijs Verkoyen, tried that google code one you linked to and I get the exact some thing. It sends the tweet fine, but javascript error on save, although the content appears to save.

It seems to be the include('twitter.class.php'); that's throwing it out.


Community Member, 254 Posts

23 February 2010 at 1:56pm

Not best practice but I whacked the twitter class above the page class, and it works. Someone must have encountered this before, I'll try and find the correct way to include a custom class.


Community Member, 904 Posts

23 February 2010 at 7:47pm

Edited: 23/02/2010 7:48pm

I wasn't sure how PHP handles includes, but after reading this: it appears that if you put an include statement inside a function, the code will be included as if it was defined in the function.
Maybe this causes the issue? Have you also tried include_once (just to be sure the class doesn't get included multiple times)?


Community Member, 254 Posts

11 March 2010 at 2:12pm

I can't remember off hand, but that is a good point. I usually include files before the class. I'll give it a whirl