Hi All,
I have developed my custom module and i am trying to change a UI related aspect.
This is the UI of my page . And i want the dropdown box which is seen at the bottom here to be seen at the top of the table.Where i have marked the blue line.
This is the function for the dashboard.


function freeway_dashboard($form, &$form_state) {

  //1. Obtain credentials from credentialProvider();
  $arrayForSendTranslation = array();
  $url_arg = "";
  $arrayForSendTranslation = credentialProvider();
  $finalFunctionUserName = $arrayForSendTranslation[0];
  $finalFunctionPassword = $arrayForSendTranslation[1];
  define("MostRecent","MostRecent");
  //2. Add javascript file
  drupal_add_js(drupal_get_path('module', 'freeway') . '/js/dashboardscript.js');

  $listOfProjectsIds = array();
  $listOfProjectsDesc = array();
  $listOfProjectsStatusCode = array();
  $node = node_load(arg(1));
  $form = array();
  $url_arg = trim($_GET['status']);


  $LoginClient = new SoapClient("https://freeway.demo.lionbridge.com/vojo/FreewayAuth.asmx?wsdl", array("trace" => 1));
  $ServicesLink = new SoapClient("https://freeway.demo.lionbridge.com/vojo/Service.asmx?wsdl", array("trace" => 1));

  if (!$url_arg) {
    try {


      $arrResponse = $LoginClient->Logon(array('Username' => $finalFunctionUserName, 'Password' => $finalFunctionPassword));

      $ticket = ($arrResponse->LogonResult);
      $getSrcLang = $ServicesLink->GetSourceLanguages(array('Ticket' => $ticket));
      $getDraftProjectIds = $ServicesLink->GetProjectSummariesList(array('Ticket' => $ticket, 'NumberOfProjects' => 100, 'SortOrder' => MostRecent, 'ProjectStatusCode' => 'Draft'));

      foreach ($getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary as $i => $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary) {

        $listOfProjectsIds[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->ID;
        $listOfProjectsDesc[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->Description;
        $listOfProjectsStatusCode[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->ProjectStatusCode;

      }


    }
    catch (SoapFault $exception) {
      drupal_get_messages();

      drupal_set_message("The following exception took place.");
      drupal_set_message("" . $exception . "");
      drupal_set_message("Kindly check Freeway mapping");

      drupal_goto("user");

    }
  }

  else {
    try {

      $arrResponse = $LoginClient->Logon(array('Username' => $finalFunctionUserName, 'Password' => $finalFunctionPassword));
      $ticket = ($arrResponse->LogonResult);
      $getSrcLang = $ServicesLink->GetSourceLanguages(array('Ticket' => $ticket));
      $getDraftProjectIds = $ServicesLink->GetProjectSummariesList(array('Ticket' => $ticket, 'NumberOfProjects' => 100, 'SortOrder' => MostRecent, 'ProjectStatusCode' => $url_arg));

      foreach ($getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary as $i => $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary) {

        $listOfProjectsIds[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->ID;
        $listOfProjectsDesc[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->Description;
        $listOfProjectsStatusCode[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->ProjectStatusCode;


      }

    }
    catch (SoapFault $exception) {
      drupal_get_messages();
      drupal_set_message("The following exception took place." . $exception . "Kindly check Freeway mapping");
      drupal_goto("user");


    }
  }

  $form['status_list'] = array(
    '#type' => 'select',
    '#title' => t('Freeway Project Statuses'),
    '#options' => array(
      0 => t('-Select Status-'),
      1 => t('Draft'),
      2 => t('NotSpecified'),
      3 => t('Quote'),
      4 => t('Forecasted'),
      5 => t('InEvaluation'),
      6 => t('Cancelled'),
      7 => t('Booked'),
      8 => t('InProduction'),
      9 => t('Completed'),
      10 => t('Closed'),
    ),
    '#default_value' => array('0' => 'Select Status'),
    '#weight' => 0,
  );


    for ($m = 0; $m < count($listOfProjectsIds); $m += 1) {
    $options[$listOfProjectsIds[$m]] = '';
   $form[$listOfProjectsIds[$m]]['projectID'] = array('#markup' => $listOfProjectsIds[$m]);
    $form[$listOfProjectsIds[$m]]['projectDesc'] = array('#markup' => $listOfProjectsDesc[$m]);
    $form[$listOfProjectsIds[$m]]['projectStatusCode'] = array('#markup' => $listOfProjectsStatusCode[$m]);
	}

 
  return $form;

}

And this is the theme:


function theme_freeway_dashboard($variables) {
  $form = $variables['form'];
  $url = "";
  drupal_add_js(drupal_get_path('module', 'freeway') . '/js/dashboardscript.js');
  global $user;
  $rows = array();
  foreach (element_children($form) as $key) {
    $row = array();
    if (isset($form[$key]['projectID'])) {
      $status = drupal_render($form['featured'][$key]);
      $row[] = array('data' => l(drupal_render($form[$key]['projectID']), 'user/' . $user->uid . '/freewayDashboardDetails', array('query' => array('project_id' => $form[$key]['projectID']['#markup']))));

      $row[] = array('data' => drupal_render($form[$key]['projectDesc']));
      $row[] = array('data' => drupal_render($form[$key]['projectStatusCode']));

      $rows[] = $row;

      l(t('Title'), $url, array('attributes' => array('target' => '_blank')));
    }

  }

  $header = array();
  $header[] = t('Project ID');
  $header[] = t('Project Description');
  $header[] = t('Project Status');

  $output = '<div class="table_overflow">' . theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('size' => 10, 'class' => array('table_class')))) . '</div>';

  $output .= drupal_render_children($form);

  return $output;


}

I have been trying to put a lighter weight for the dropdownbox. But it still lies at the bottom. Is it due to the theme that the dropdown box sinks to the bottom?

Would like to have your views.
Angie.

Comments

petebarnett’s picture

You've got it :)

drupal_render respects weights, but it can't change what you do with the output it gives you...

In this code, you're explicitly rendering certain elements and building a table with them, and initialising your $output variable with this content.
You're then rendering the remaining (so far unrendered) form elements with your drupal_render_children call, and adding this to your variable.

No amount of weight fiddling can change the fact that you're manually building up the output here. You've explicitly added the table first, and left the rest til last.

You just need to start your output with the select list:
$output = drupal_render($form['status_list']);

and let the table, and remaining elements be added after.

Peter

theamoeba’s picture

Change:


$output = '<div class="table_overflow">' . theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('size' => 10, 'class' => array('table_class')))) . '</div>';

$output .= drupal_render_children($form);

to:


$output = drupal_render_children($form);
$output .= '<div class="table_overflow">' . theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('size' => 10, 'class' => array('table_class')))) . '</div>';

angela.simmons’s picture

Thanks Jon this solution worked!

A