I have a custom style-plugin ("mymodule_style1") and an associated style-template ("mymodule-views-plugin-style1-template.tpl.php"), which is declared in hook_views_plugins:
function mymodule_views_plugins() {
$plugins = array(
'style' => array(
'mymodule_style1' => array(
'handler' => 'mymodule_views_plugin_style1',
'theme' => 'mymodule-views-plugin-style1-template'
...
),
),
);
return $plugins;
}
To create the template, I simply cloned views-view-unformatted.tpl.php.
Here is the template:
<?php if (!empty($title)): ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
<div <?php if ($classes_array[$id]) { print 'class="' . $classes_array[$id] .'"'; } ?>>
<?php print $row; // error. "Object of class stdClass could not be converted to string" ?>
</div>
<?php endforeach; ?>
When I try to display my view, I get this error:
Recoverable fatal error: Object of class stdClass could not be converted to string in include() (line 12 of o4mmgal-views-plugin-style1-template.tpl.php).
The error is on the line print $row.
When I look at the theme information, in the views ui, "Row style output" is not listed.
Display output: views-view.tpl.php, views-view--myview.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--page.tpl.php, views-view--myview--page.tpl.php
Style output: mymodule-views-plugin-style1-template.tpl.php, mymodule-views-plugin-style1-template--myview.tpl.php, ...
Field Content: Title (ID: title): views-view-field.tpl.php, views-view-field--title.tpl.php, ...
...
Why are the default row-style templates not listed? Is it possible to use views-view-fields.tpl.php to print $row?
Thanks very much
Comments
Comment #1
mustanggb commented