Hi Team Silverstripe,
First of all I would like to thank you for the well structure web platform. I am facing some issues with nested loop. Due to limited resources, problem is taking longer than usual.
I am not able to pass parent loop value into the child loop. Check the code below for the reference:
-------------------------------Code Start-------------------------------
controller code :
public function editPostjob(){
$job_id = $this->getRequest()->getVar(‘id’);
$relief_job = “SELECT * FROM vismaad_jobs where id=$job_id”;
$relief_job_data = mysqli_query($this->connect,$relief_job);
$array = new ArrayList();
if(mysqli_num_rows($relief_job_data) > 0){
while($fetch = mysqli_fetch_assoc($relief_job_data)){
$days = date_diff(date_create($fetch[‘from_date’]),date_create($fetch[‘to_date’]));
$total_days = $days->format("%r%a");
$job_profile_id = $fetch[‘job_profile’];
$job_profile = “SELECT * FROM vismaad_job_profiles where id=$job_profile_id”;
$job_profile_data = mysqli_query($this->connect,$job_profile);
$fetch_profile = mysqli_fetch_assoc($job_profile_data);
$job_profile_title = $fetch_profile[‘title’];
$arrayData = new ArrayData(array(
'id' => $fetch['id'],
'category' => $fetch['category'],
'job_description' => $fetch['job_description'],
'name_of_job_post' => $fetch['name_of_job_post'],
'daily_rate' => $fetch['daily_rate'],
'from_date' => $fetch['from_date'],
'to_date' => $fetch['to_date'],
'job_location_state' => $fetch['job_location_state'],
'job_location_city' => $fetch['job_location_city'],
'created_at'=> $fetch['created_at'],
'days' => $total_days,
'job_profile' => $job_profile_title,
'job_sub_profile' => $fetch['job_sub_profile'],
'desired_place' => $fetch['desired_place'],
'no_of_hiring' => $fetch['no_of_hiring'],
'shift' => $fetch['shift'],
'posted_by' => $fetch['posted_by'],
'total_price' => ($fetch['daily_rate']*$total_days),
'job_id'=>$job_id,
'status' => $fetch['status'],
));
$array->push($arrayData);
}
return $array;
}
}
public function getProfile() {
$job_profile = "SELECT * FROM vismaad_job_profiles";
$job_profile_data = mysqli_query($this->connect,$job_profile);
$array = new ArrayList();
if(mysqli_num_rows($job_profile_data) > 0){
while($fetch = mysqli_fetch_assoc($job_profile_data)){
$arrayData = new ArrayData(array(
'id' => $fetch['id'],
'title' => $fetch['title'],
));
$array->push($arrayData);
}
return $array;
}
}
in template.ss
<% loop $editPostjob %>
<% loop $Up.getProfile %>
Qucik response would be appreciated.
Thanks
Rupinder Singh