This is probably a bug because you are checking twice the `/view/` folder. I gues this line should be:

```php
$file = JPATH_SITE . '/components/' . $item->componentname . '/views/' . $vars['view'] . '/tmpl/' . $vars['layout'] . '.xml';
```

Also remember that Joomla! coding standards require spaces before and after dots when concatenating strings.