Active
Project:
AJAX Views
Version:
5.x-1.0
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
18 Jan 2008 at 17:48 UTC
Updated:
18 Jan 2009 at 12:03 UTC
Jump to comment: Most recent file
Per default a Ajax Views Block renders an item list of node titles. I would like to show other fields of my underlying view, such as the teaser and a image field. How can I achieve this?
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | ajax_views.zip | 3.71 KB | mavimo |
Comments
Comment #1
febbraro commentedYou can implement theme_views_ajax_page_item it passes a parameter $node as returned from the view. If you want more fields be sure to add them to the Fields section of the view.
Comment #2
mdroste commentedIt works. Thanks.
Comment #3
febbraro commentedGlad it worked :-)
Comment #4
mavimo commentedThis don't work fine.
I've create a new views with page and block. Page is a list views, block is ajax views, if i go to page /demo-ajax-views I correctly see fields added into views, but if I use block, only title is aviable (also with own theming function into template.php). I hacked the ajax_views code, and find some problem; views don't return full node if $views->type = 'page', but only $node->nid object.
Let me explain, if I add a print_r into theme_views_ajax_page function I see only an array of node object similar to:
not a complete node with fields. If I add this block it's called correctly and fields are correctly aviable:
Other information:
I'm intresting to correct this "bug", but i need collaboration, plz contat me.
Bye
Comment #5
febbraro commentedI can help you with this, but it might be some time. I am leaving for vacation tomorrow and will return on June 10th.
Comment #6
mavimo commentedOk, if you can get me some input I'm starting work :D
Comment #7
febbraro commentedThe problem is that the main theme function is never "collecting" all of the fields. If you use the theme wizard, the part they tell you to put into your template.php file basically collects the values for you. To give you a push in the right direction I might suggest this 2 things.
#1 The default Page themer loads all of the nodes for you. If you need to override how a particular node is rendered, you should just be able to implement views_ajax_page_item and it will get called for each node in your view results after a call to node_load so all of you data should be around.
If that does not work, try something like the following....
In theme_views_ajax if it is a page type, take hints from the theme wizard and do something like..
I could be waaaaaaay off with what this code actually does, but basically you want to process each and every field specified on the view and load it's data and set it on the $node. Or you could simply node_load it, or build some entirely different data structure that you pass to the theme function. I think this should give you a push in the right direction, sorry I can't help more, but I could not be MORE in need of a vacation right now. :-)
I'll jump back in and help on my return. Good luck, I'll be checking emails if you have questions but not too frequently.
Frank
Comment #8
mavimo commentedI had this solution before posting message but don't work fine. With node_load i load only main element of node, not complete node with fields & c. (similar fivestars widget, ...) I think generate it from DB is not best way for future extendibility function. If i go to correct page (not in ajax_views) I recive correct info, but into ajax_views this don't work. I'll debug the code, have a nice vacation.
Marco
Comment #9
klaasvw commentedI had a similar problem but I think I found the solution.
First of all you're right you'll need to write your own theme_views_ajax_page_item_viewname($node) theme function. Here you can output all your node fields. If you don't exactly know how they're called do var_dump($node).
There's still one problem though. Some fields aren't rendered as they should. I had this problem with a cck content type that used fivestar and op_video fields.
The trick is making sure you call node_view first. That way all cck fields will be rendered before you're displaying them.
So what I did is calling this in my theme_views_ajax_page function for each node:
module_invoke_all('view', $current), $current being the $node you want to render.
Anyway, it would be awesome if you could make the AJAX block view type similar to a list view type, so that it will include the fields chosen in the view automatically instead of just the titles.
Besides this tiny issue it's an awesome module though :)
Comment #10
klaasvw commentedLittle update on my previous findings:
Please replace module_invoke_all('view', $current) with node_view($current) or node_view($current, TRUE).
For some reason this gave privatemsg errors.
Comment #11
mavimo commentedNo solution, but just a little update after a long time debugging; into function ajax_views_ajax_argument if I change 'ajax_views' with 'list' a complete page list occur (oks), after that i test to change, into module views, this function:
And content appair correctly into block, filed are correctly themed, and all it's ok, but if i copy this code into file ajax_viers.module, into function theme_views_ajax_page don't work :|
some one can explain me why this function work if have some name and not if have another name into other file?
Bye
Mavimo
Comment #12
mavimo commentedSome improvement:
change, into files views.module the function theme_views_view_list() to:
this is not the good solution, but only a temporary solution!!!
After that chage your ajax_views.module with file into attchment.
Current change:
next improvement
Bye
Mavimo
Comment #13
asak commented@mavimo: I've done what you described in comment #12 but have a problem:
The AJAX formatter is gone, both for the page view and the block view. the argument for ajax is still there.
Any idea where could it go... should it just disappear?
Before changing the files, I got a working AJAX pager in a block, which displayd the titles of the nodes.
Now I get an empty block.
What I want is to display a table with a pager.
Comment #14
asak commentedThe page view displays the correct list of nodes, with the fields i've selected.
The problem is with the ajax_views.module file.
I will try and see what's going on.
Comment #15
hawk007 commentedI use these two functions in the template.php, the first is the one that creates the span of all content, the second makes each item of the view:
function theme_views_ajax_page
in this function is where I created a custom template
function theme_views_ajax_page_item
is very important that we take the view that the pager activated and the type page has a URL
Comment #16
Ehud commentedHi,
Those two functions helped me display node fields only when the call to the view was embeded in a node or as a block. it works great.
But when i embed the call to the view in the front page(page-front.tpl.php), it doesn't show. i only get the progress.gif and the view content is empty.
Please help me understand the difference (between page.tpl.php and page-front.tpl.php) and what can solve that problem.
Thanks a lot!