The best to do this is using theme layer. In your case,views-view-grid.tpl.php
is used to display the results.
There are different ways to alter that.
Solution A: Using template preprocessors
Add this function to template.php
in your theme folder.
<?php
/**
* Implements hook_preprocess_views_view_grid().
*
* Check if there is no result for this group and provide an appropraite message.
*
*/
function phptemplate_preprocess_views_view_grid(&$variables) {
$view = $variables['view'];
if ($view->name == 'YOUR_VIEW_NAME') { // Only do this for a specific view
if (empty($variables['rows'])) {
$variables['caption'] = t('No results.');
}
}
}
Solution B: Overriding the template file
Copy views-view-grid.tpl.php
to your theme folder and then modify it.
You may also want to rename the template file so it would only apply to a specific view. (Learn how to find the appropriate template file name for Views).
<?php
/**
* @file
* Default simple view template to display a rows in a grid.
*
* - $rows contains a nested array of rows. Each row contains an array of
* columns.
*
* @ingroup views_templates
*/
?>
<?php if (!empty($title)) : ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<?php // We check if there is no result we print a meesage ?>
<?php if (empty($rows)) : ?>
<?php print t('No results.'); ?>
<?php endif; ?>
<table class="<?php print $class; ?>"<?php print $attributes; ?>>
<?php if (!empty($caption)) : ?>
<caption><?php print $caption; ?></caption>
<?php endif; ?>
<tbody>
<?php foreach ($rows as $row_number => $columns): ?>
<tr <?php if ($row_classes[$row_number]) { print 'class="' . $row_classes[$row_number] .'"'; } ?>>
<?php foreach ($columns as $column_number => $item): ?>
<td <?php if ($column_classes[$row_number][$column_number]) { print 'class="' . $column_classes[$row_number][$column_number] .'"'; } ?>>
<?php print $item; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>