Jump to content

Returning titles from $input->get instead of names


a-ok
 Share

Recommended Posts

Is there any way to return <?php $sectors = $input->get->project_sectors; ?> as the titles, and not the names? So instead of, for example, it returning landscape-design (the name) it would return Landscape Design (the title).

Thanks,

R

Link to comment
Share on other sites

If you can't hide the titles in a hidden input that could be sent via post, then you would need to find the pages on the fly, e.g.

$error = "Your error message";
$sectors = $sanitizer->pageName($input->get->project_sectors);
if(strlen($sectors)) {

	$sector = $pages->get("name=$sectors");//could make your selector more specific, e.g. specify template
	if($sector && $sector->id > 0) {
		$sector = $sector->title;
		//do something with $sector
	}	
	else {//display error or similar 
	}
}

else {
	//display error or similar since given input was empty
}
Edited by kongondo
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...