Views output like the core teaser lists?
-Anti- - April 17, 2009 - 11:58
I can't find this anywhere...
How do you make views output a teaser list that uses exactly the same styling as your node.tpl.php?
Do you have to theme the view yourself from scratch? Or is there a quick way that I'm missing?
This should be an easy thing to do in views, shouldn't it? I imagine lots of people wanting the core
teaser list with an exposed filter at the top, or sortable column headings.
Cheers.

using "node" view style?
Not sure if I understood correctly.
Also not really a Drupal expert, but if you set the style of the view to node and in the options you specify show teasers only you should get a list of teasers filtered according to the other view settings (arguments, relationships, ...).
Then you can enable any exposed filter to allow the user to select content accordingly.
At least this is what I did with the default taxonomy_term view.
Concerning sortable column headings, I think you need a table listing, therefore, I guess, you have to set the style of the view to fields; in this case you'll prolly lose the styling of each field.
Hope this helps
Ah yes! Thank you. Style:
Ah yes! Thank you.
Style: unformatted
Row style: Node -> style settings -> build mode: teaser
I assumed unformatted meant 'un-themed', as the 'preview' was un-themed.
But when the actual site is viewed, it is themed by node.tpl.php
> Concerning sortable column headings, I think you need a table listing
What I really wanted was a teaser-list with an exposed filter for a profile field (name) as opposed to using the username. Apart from users being able to type the real name instead of the login name, it would also has the advantage that the username autocomplete has to be spelled correctly from the beginning, whereas a profile-field 'search' can take any part of the name string.
However, everytime I try to use an exposed filter from the profile, I get an error.
I also get an error when I try to use the Views example 'tracker view' for 'my recent posts'.
I wonder if these things are broken for everyone, or if there is something wrong with my database?
Cheers.
_
I can confirm i have exactly this working with d6.10 and views 2.4. What error are you getting?
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
> I can confirm I have
>> I also get an error when I try to use the Views example 'tracker view' for 'my recent posts'.
I researched this an found other with the same problem; the core tracker should be disabled.
> I can confirm I have exactly this working with d6.10 and views 2.4
I'm using views 6.x-2.5
PHP version is 5.2.8
MySQL version is 5.0.67-community
> What error are you getting?
Two errors. I notice now that the filter doesn't even need to be exposed to trigger the error.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-name ON users.uid = profile_values_profile-name.uid AND profile_values_profile-' at line 4 query: SELECT COUNT(*) FROM (SELECT DISTINCT(node.nid) AS nid FROM node node INNER JOIN users users ON node.uid = users.uid LEFT JOIN profile_values profile_values_profile-name ON users.uid = profile_values_profile-name.uid AND profile_values_profile-name.fid = '1' WHERE (node.status <> 0 OR node.uid = 1 or 1 = 1) AND (node.type in ('blog')) AND (UPPER(profile_values_profile-name.value) LIKE UPPER('%string goes here%')) ) count_alias in /home/user/public_html/dev/sites/all/modules/views/includes/view.inc on line 705.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-name ON users.uid = profile_values_profile-name.uid AND profile_values_profile-' at line 4 query: SELECT DISTINCT(node.nid) AS nid FROM node node INNER JOIN users users ON node.uid = users.uid LEFT JOIN profile_values profile_values_profile-name ON users.uid = profile_values_profile-name.uid AND profile_values_profile-name.fid = '1' WHERE (node.status <> 0 OR node.uid = 1 or 1 = 1) AND (node.type in ('blog')) AND (UPPER(profile_values_profile-name.value) LIKE UPPER('%string goes here%')) LIMIT 0, 20 in /home/user/public_html/dev/sites/all/modules/views/includes/view.inc on line 731.
Here's the query:
SELECT node.nid AS nidFROM node node
INNER JOIN users users ON node.uid = users.uid
LEFT JOIN profile_values profile_values_profile-name ON users.uid = profile_values_profile-name.uid AND profile_values_profile-name.fid = '1'
WHERE (node.status <> 0 OR node.uid = ***CURRENT_USER*** or ***ADMINISTER_NODES*** = 1) AND (node.type in ('blog')) AND (UPPER(profile_values_profile-name.value) LIKE UPPER('%string goes here%'))
Thanks for looking at it!
_
Here's my query:
SELECT node.nid AS nidFROM node node
INNER JOIN users users ON node.uid = users.uid
LEFT JOIN profile_values profile_values_profile_fullname ON users.uid = profile_values_profile_fullname.uid AND profile_values_profile_fullname.fid = '2'
WHERE (node.status <> 0) AND (node.type in ('blog')) AND (UPPER(profile_values_profile_fullname.value) LIKE UPPER('%string%'))
And the exported view:
$view = new view;$view->name = 'test_fullname_filter';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'blog' => 'blog',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
'value' => array(
'operator' => '=',
'value' => '',
'group' => '0',
'exposed' => TRUE,
'expose' => array(
'use_operator' => 1,
'operator' => 'value_op',
'identifier' => 'fullname',
'label' => 'Profile: Full Name',
'optional' => 1,
'remember' => 1,
),
'case' => 0,
'id' => 'value',
'table' => 'profile_values_profile_fullname',
'field' => 'value',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('row_plugin', 'node');
$handler->override_option('row_options', array(
'relationship' => 'none',
'build_mode' => 'teaser',
'links' => 0,
'comments' => 0,
));
I'm not sure how you got the current_user or administer_nodes stuff in there-- not sure why you would want to expose a filter for author name on a view that only shows nodes authored by the user, lol, but whatever.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
Thanks for posting that
Thanks for posting that info.
> not sure why you would want to expose a filter for author name
> on a view that only shows nodes authored by the user
Don't know. I chose 'published or admin' thinking that meant 'admin sees both published & unpublished, and everyone else only sees what they have permission to see'. The view itself is supposed to show all blog posts tagged with a certain school 'year group' (eg. 'Y5'), which is provided through an argument in the url. Then the exposed filter is supposed be so the students can cut it down further. Eg 'all blog posts for Y5 written by Mr. Strict'.
I'm still looking into this problem. I've since tried other views and found out that I cannot add profile paramaters to any section in any view without getting the same error. So the problem isn't specific to the view I posted.
The next thing I'm going to try is to roll back to Views 6.4.
Thanks for your help.
EDIT:
Rolling back to views 6.4 didn't help
_
Ah ok-- I'd never seen that filter before. I switched to that, now my query is:
SELECT node.nid AS nidFROM node node
INNER JOIN users users ON node.uid = users.uid
LEFT JOIN profile_values profile_values_profile_fullname ON users.uid = profile_values_profile_fullname.uid AND profile_values_profile_fullname.fid = '2'
WHERE (node.status <> 0 OR node.uid = ***CURRENT_USER*** or ***ADMINISTER_NODES*** = 1) AND (node.type in ('blog')) AND (UPPER(profile_values_profile_fullname.value) LIKE UPPER('%string%'))
I also updated to views 2.5-- still no problem, view works fine. I'm not sure what it could be. Maybe delete and re-download the profile module code (modules/profile)?
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
Hey, thank you for trying
Hey, thank you for trying again and posting your query.
· I completely uninstalled views, but the problem persisted.
· Luckily I have a near exact copy of my (still in development) website on another host.
I went to that version and tried adding a profile parameter to a view, and it worked without problem.
So, I'm thinking it might be the SQL version.
The site it worked on is running 'cpanel 11.24.4-CURRENT' with 'MySQL 5.0.77-community'.
The site it is broken on is running 'cpanel 11.24.4-RELEASE' with 'MySQL 5.0.67-community'.
I'm now looking at how to upgrade mySQL in WHM without having to upgrade WHM/cpanel to current. I guess that would be easier than for Views developers to fix a particular bug with a particular SQL.
Thanks for your input.
_
Don't mean to punch a hole in your theory, but my server is running MySQL 5.0.67-community ;-0
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
Yep. To double check I moved
Yep. To double check I moved my current site back to the old host and it failed.
So what ever the problem is, it it must have happened in the last two weeks.
At the moment I'm looking at the user import module as the possible culprit. I posted an issue on the project page: http://drupal.org/node/437462 Yeah, I know, in retrospect I should have dug deeper into this in the beginning. But everything about the imported user tables seemed ok, so I skipped it early on as a probable cause. In light of the 'profile_values table' issue posted on the project page, it now seems quite likely to be the cause.
Thank you very much for your help.
I would have been totally lost without your feedback and testing.
_
Yeah-- certainly sounds like a possibility.
Happy to help ;-)
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
I need to do one final test,
I need to do one final test, but I think I found the problem.
OK, you are not going to believe this....
My profile field is called profile-name
Stemming from my aesthetic preference for hyphens over underlines.
And it seems to be just this hyphen which is baulking mySQL.
'... for the right syntax to use near '-name' was a clue in
the error but because I don't know the first thing about SQL, I
didn't dissect the error enough to catch it.
So simple, yet so time consuming (14 hours) and stressful. I'm going to get my wife to kick me up the arse, hard. Lesson learnt - just because there is a large block of red text, of which you understand not one line, don't freak out and immediately assume that your database is hosed, and that it's caused by something you don't understand which is out of your control.
Again thanks for your input, although now I feel like I wasted your time as well as mine!
_
I believe you're correct-- i just went and changed my profile field from "fullname" to "full-name" and received the same error you did. Changed it to "full_name" and it works fine.
It's a shame something so small can suck up so much time to diagnose, ;-(
And you're welcome again ;-)
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
> It's a shame something so
> It's a shame something so small can suck up so much time to diagnose
If I knew anything about SQL I would have seen it. In retrospect, I can understand exactly what the error was telling me. At the time it just looks like a foreign language (I suppose it is in a way).
I posted the issue on the Views2 issue page, although I'm not sure what is at fault - core or Views.
Anyway, I'm a very happy chappy now, and the exposed profile field works GREAT for searching! It accepts partial matches (although not spelling mistakes). But still much better for that than the autocomplete field supplied for the 'username' parameter (it only accepts the exact string from the beginning, and might even be case matched from what I remember - nearly useless!).
Cheers again!