By XBleed on
Hey guys, I'm pretty close to getting this one finished here..
I'm themeing a view inside of my template.php file like so:
function themename_views_view_list_view_name($view, $nodes, $type) {
$fields = _views_get_fields();
foreach ($nodes as $node) {
$item = '';
foreach ($view->field as $field) {
$item .= views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view);
}
$items[] = "<div class=\"span-4\">$item</div>\n";
}
if ($items) {
return implode("",$items);
}
}
I'm calling the view inside of a Page node type like so:
$view = views_get_view('view_name');
print views_build_view('block', $view, array($title), false, 4);
I need to add "last" to the $items[] div on the fourth view item that is being called so that the generated code displays this:
<div class="span-4">VIEW ITEM</div>
<div class="span-4">VIEW ITEM</div>
<div class="span-4">VIEW ITEM</div>
<div class="span-4 last">VIEW ITEM</div>
I'm so close, but so far. Anyone have any ideas?
Thanks.
Comments
Okay, well I seem to have it
Okay, well I seem to have it working now..
I kind of had to rig it to work, so my view theme function now looks like this:
I imagine there's a more "Drupal" way to do this though. Anyone have a more efficient way of achieving this than what I have come up with?
Thanks.
Try this...
___________________
It’s in the detaιls…
demonstration portfolio
together with tpl.php file ?
is there a way to let this work together with a tpl.php file,
so you can add divs for the 'general' output in the tpl.php file
and specific divs through the function.
in other words get this functionality combined:
What's the problem?
What have you tried?
What are the symptoms?
I think that;-
is not going to do what you expect!
___________________
It’s in the detaιls…
demonstration portfolio
Generalise span #
___________________
It’s in the detaιls…
demonstration portfolio
other way
Thanks for the reply, but that's not what I meant:
If I wanted a general wrap around the node, I would just add it in a tpl.php file.
I want my nodes come out with the divs I added in tpl.php and an unique wrap div around them.
say:
div id="node1"
div class="title"
div class="body"
div id="node2"
div class="title"
div class="body"
div id="node3"
div class="title"
div class="body"
div id="node4"
div class="title"
div class="body"
Makes sense now? title and body are added in tpl.php, the node-number are added through template.php
?
Have you replied to the correct comment? My comment is a reply to my previous comment .
Then again, I’m not sure how this relates to either.
If you want
<div id="node1">...</div>, you can put<div id="node<?php print $id; ?>">...</div>in node.tpl.php.___________________
It’s in the detaιls…
demonstration portfolio