I am working on a view which has a dropdown button at the end, and a template file to build that dropdown. The problem I am getting is that the rows are off by 1; such that the view data is out of sync with the template. Hopefully you can see what I mean from screenshots:

Notice how with that one the Change is for nid 8575, which is the previous row.

The view:

The dropbutton template code:

global $user;

 

$rolevar = torch_rolevar($user);

$suffix='?';

if($rolevar!=5){

$suffix.='destination=heart/applications';

} else {

$suffix.='destination=heart/my_org_applications';

}

$suffix.='&width=90%&height=90%&iframe=true';

 

$nid=$field->last_tokens['[nid]'];// used to provide unique handler for dropdown clicker: get node id

$status= torch_get_status();

$output='';

$sid=$field->last_tokens['[field_appstatus]'];// used to provide unique handler for dropdown clicker: get status id

 

if($nid){

foreach($status as $k=>$v){

 

if($v['id'] !=$sid){

$link='/node/'.$nid.'/edit/status/'.$v['id'].$suffix;

$name=ucfirst($v['name']);

$title=$name;

$class='status-'.$v['id'];

$output.='<li class="dropbutton-action secondary-action"><a href="'.$link.'" class="'.$class.'" title="'.$title.'">'.$name.'</a></li>';

}

}

}

if(!empty($output)){

?>

 

<div class="dropbutton-wrapper">

<div id="status-changer" class="dropbutton-widget">

<ul class="dropbutton" style="min-width: 104px;">

<li class="first dropbutton-action" onclick="clickToggle('drop<?php print $nid; ?>')"><a href="#" title="Change status of Application <?php print $nid; ?>">Change</a></li>

<li class="dropbutton-toggle"><button type="button" role="button"><span class="dropbutton-arrow" id="drop<?php print $nid; ?>"><span class="visually-hidden">List additional actions</span></span></button></li>

<?php echo $output; ?>

</ul>

</div>

</div>

<?php } ?>

 

Accepted answer

I deleted the view, and rebuilt it with the same fields and settings, AFAIK...now it goes. Weird.

Comments

I deleted the view, and rebuilt it with the same fields and settings, AFAIK...now it goes. Weird.