Moshe and merlinofchaos for pointed me in the right direction for the function to modify if you want to remove divs that are output in a list view block via the Views module. To strip out those divs, do something like below in your PHP Template's template.php file:
function phptemplate_views_view_list($view, $nodes, $type) {
$fields = _views_get_fields();
foreach ($nodes as $node) {
$item = '';
foreach ($view->field as $field) {
if ($field['label']) {
$item .= '<div class="view-label view-label-$field[queryname]">'. $field['label'] ."</div>";
}
$item .= views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view) . "<br />";
}
$items[] = "$item"; // l($node->title, "node/$node->nid");
}
if ($items) {
return theme('item_list', $items);
}
}Thanks to everyone for the suggestions.
Comments
03/07/07 @ 17:20
If I can actually get this to work, I'll owe you a beer. That is, if you drink.
So you're saying this function should be inserted into the theme's template.php file, correct? Should it work without alteration in most themes? I understand PHP enough to get the basics of what it's doing, but I can't figure out what I might need to change to make this work on my site.
I should mention: my homepage is WordPress, not Drupal - I only have a very VERY early stage Drupal site up for testing purposes. The only view block I have set up is a "Top Nav" list here: http://thenestedtest.com/drupal The site couldn't be uglier - I've decided to use the Sympal theme to develop on, simply because it ouputs the cleanest, most minimal HTML. The site I'm ultimately porting to drupal is here: http://southernenvironment.org
Do you have ANY idea what I might need to change to get the function you've authored to work?
Thanks a million for posting this!
03/07/07 @ 17:35
Oh, crud.
I just realized I may have made an @ss out of myself. The block I'm trying to strip divs from is a menu block. Huh.
Would it be terrible if I created a block that wasn't a menu and used it as a nav bar, would that be a bad idea?
Nevermind me if I'm talking gibberish...I think I'm a good six months away from understanding Drupal.
03/07/07 @ 18:10
I can't imagine that you're using the Views module to generate that list. The code above is to strip out the extra divs that the Views module puts out. I'm not understanding what's going on for you.
07/25/07 @ 09:12
Good tip. I need to try it to remove div tags in my project. It's really PIA for me now :S
08/14/07 @ 06:48
Sorry, how to use this tip in WordPress?
08/14/07 @ 09:55
This is a tip related to Drupal Views module.
08/20/07 @ 05:25
Thank you for mentioning Sympal theme. The most themes has terrible html code...
09/10/07 @ 00:50
you need to update your Drupal, even for testing purposes, as you are not getting a good indication with results from that early of a release
12/11/07 @ 02:51
Yes Sympal is quite the theme. Doesn't have all the computer security problems that the others do...
01/20/08 @ 07:54
And I thought lerning Italian was hard - man there's so much to learn about Drupal...
01/27/08 @ 10:18
The most themes has terrible html code...
andrzej
http://www.andrzejfilipowicz.com
01/27/08 @ 19:54
Thank you for mentioning Sympal theme.
gta vice city
02/21/08 @ 15:45
Charity cds: ofcourse learning something you have ever known is hard at the beginning.
03/01/08 @ 18:46
I created 10 to 15 different block views and all use the generated codes by views theme wizard which produced function phptemplate_views_view_list_VIEWNAMEs with all the same codes but for the VIEWNAMEs . Putting all those similar codes into my template.php seems to be irrational.
Does anyone here in this resourceful site know how to combine those functions so that I can at least eliminate code duplications?
Any help would be appreciated. Thanks.
07/08/08 @ 02:05
Thank you for post.
07/23/08 @ 06:01
Nice tip.
Question:
is that code created for D5 or D6 theme (or both)?
07/23/08 @ 13:39
That's for Drupal 5. Not tested in 6.
Post new comment