This was so easy to do in D6, now I am trying to get up to speed using Drupal 7. I have been going at this for hours but can't seem to find a way to manually print fields from a view into a custom view page.
In D6 I used to create a views template,
for example: views-view-fields--video--block-1.tpl.php
Then in there I would give my custom css wrap around the field code like this
print $fields['field_video_link_embed']->content; print $fields['title']->content;
print $fields['body']->content;
Now when in Drupal 7 I try to put in the new views template, I get an error:
Notice: Undefined variable: fields in include() (line 52 of /templates/views-view--message-post--block.tpl.php).
Notice: Trying to get property of non-object in include() (line 52 of /templates/views-view--message-post--block.tpl.php).
Does anyone know how to bring over the fields manually
Comments
_
I'm not sure about how the syntax has changed, but just do a print_r (dsm if you use devel) on the $fields array to see the structure.
Under theme settings in Views
Under theme settings in Views UI, look for the Row style output. (NOT style output). $fields variables is not available in Style Output.
Thanks Arshad, that was it, I
Thanks Arshad, that was it, I was using the wrong theme file.
What is a quick way to see all the fields names without having to go through the Views UI?
I tried using this but my page comes up empty after I add it in.
I also use devel, but don't know what the shortcut is to add it in.
The devel function is
The devel function is dsm().
...so how do I print
...so how do I print 'title'?
?
That would print the group title (what ever that is :-) )
To print the title of the view you can use
print $view->get_title();At least, that works for me to get the title of the view printed via the template.
the same
I'm have the same problem. I have the file: views-view-unformatted--products.tpl.php.
In that file I have:
print $fields['field_product_exterior_width']->content;Once saved and uploaded my view gets the errors:
Notice: Undefined variable: fields in include() ....
Notice: Trying to get property of non-object in include() ....
This should be easy but I have been on this for days.
Thank you in advance
Same issue here
Hi Ariel,
I have the same issue. Have you find any solution for this?
Prancz Ádám
Könyvelés, adótanácsadás, webdesign
try using devel module
copy this code in your template to see available data in your view
_
Like this https://drupal.org/comment/5119500#comment-5119500?