I get this error when adding the field: Twitter: Follow to a view. I get as many times as tweet are shown.

Notice: Undefined property: stdClass::$twitter_screen_name en twitter_views_handler_field_follow->render() (line 127 of /home/example/www/sites/all/modules/twitter/twitter_views_field_handlers.inc).

Line 127 is:

/**
 * Adds Twitter Follow link.
 *
 * @see https://dev.twitter.com/docs/intents#follow-intent
 */
class twitter_views_handler_field_follow extends views_handler_field {
  function query() {}

  function render($values) {
    drupal_add_js('//platform.twitter.com/widgets.js', 'external');
    return '<span><a href="https://twitter.com/intent/user?screen_name=' . $values->twitter_screen_name . '">Follow</a></span>'; //LINE 127
  }
}

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chefnelone’s picture

Issue summary: View changes

info

Rhodungeon’s picture

Same error for me!

fjgarlin’s picture

Same here. Even changing the rewriting of the field it still happens. Also, in the preview screen for the view doesn't seem to show the error. Any clues?

When var_dumping the content of values on that line the result is a property called "twitter_account_screen_name" rather than "twitter_screen_name".

fjgarlin’s picture

Issue summary: View changes

more

Verban’s picture

Issue summary: View changes
FileSize
659 bytes
chris_slater’s picture

did this fix it for you? I applied 2032057-2.patch and it didn't clear it up.

tr-communication’s picture

Hello
Up
I have the same error ...
Anyone for more instructions ?
Thanks

MarcoR’s picture

Status: Active » Needs review

The patch #3 https://drupal.org/comment/8304053#comment-8304053 fixed it for me. Thanks!

estoyausente’s picture

Status: Needs review » Reviewed & tested by the community

It's seem be ok. And the patch apply perfectly.

preksha’s picture

I have applied patch given in #3 but still it doesn't work. It gives me an error like:

Notice: Undefined property: stdClass::$twitter_account_screen_name in twitter_views_handler_field_follow->render() (line 128 of /var/www/example/sites/all/modules/contrib/twitter/twitter_views_field_handlers.inc).

Now it gives an error for twitter_account_screen_name..

Does any one has any idea?

preksha’s picture

Ok, got the solution.

The php code is as follow where I got the error:

/**
* Adds Twitter Follow link.
*
* @see https://dev.twitter.com/docs/intents#follow-intent
*/
class twitter_views_handler_field_follow extends views_handler_field {
  function query() {}
  function render($values) {
    drupal_add_js('//platform.twitter.com/widgets.js', 'external');
    return '<span><a href="https://twitter.com/intent/user?screen_name=' . $values->twitter_screen_name . '">Follow</a></span>'; //LINE 127
  }
}

Here if you print the $values, you will get object but in that twitter_screen_name is missing. This object will give you the properties which are included as fields in views.

So solution for this is to add "Twitter: Login name" field which relates the twitter account screen name in your views and mark it as exclude from display if you don't want to display. So that in $values object it will get the twitter account screen name property value.

This works for me.

Staler75’s picture

#3 didn't work for me

#9 i don't understand, can you explain more? like were to make the field, did you put some extra code etc.

thanks in advance

womblebomble’s picture

@Staler...

the problem lies with this "follow" field be dependent on the existence of another field called "Login name". Once you add this the problem goes away.

So within the twitter view click "Add" within Fields section and look for the following field...

"Twitter: Login name
The screen name of the author of the tweet."

That should fix it.

P.S. remember to tick "Exclude from display" within the "Configure field: Twitter: Login name" if you don't want this field showing up.

Staler75’s picture

Ahh okey i understand now, i was thinking to hard :)

thnx for the quick respond.

nicxvan’s picture

It needs to be the author field, not the user field.

DamienMcKenna’s picture

Status: Reviewed & tested by the community » Needs review
Parent issue: » #2402309: Plan for Twitter v7.x-6.0 release

Triggering the testbot.

Status: Needs review » Needs work

The last submitted patch, 3: twitter-fix-screen-name-2032057-2.patch, failed testing.

DamienMcKenna’s picture

Status: Needs work » Needs review

DamienMcKenna’s picture

Title: Error when adding the field: Twitter: Follow to a view. » Error when adding the field: Twitter: Follow to a view
Version: 7.x-6.x-dev » 7.x-5.x-dev
FileSize
2.08 KB

This checks a few possible values for the screen name.

DamienMcKenna’s picture

This affects both the 7.x-5.x and 7.x-6.x branches.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed 6022ce2 on 7.x-5.x
    Issue #2032057 by DamienMcKenna, Verban: Check a few values to see if...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.