Jump to content

Change Select Options title to lowercase


louisstephens
 Share

Recommended Posts

Does anyone know how to change the title of a select options to lower case? Right now, I have 3 options: "Management, Editor, Guest" (titles are uppercase in the backend), and I would like to change them to lower case in my template as I am adding them as a class name to span tags, ie "<span class="management"></span>".

I will note, that I am using $level->title (the options) in a nested foreach loop, if this changes anything. Also, I thought I could use strtolower(), but it is just being "echo'd" in the source code.

Link to comment
Share on other sites

21 minutes ago, elabx said:

This works??


 strtolower($page->options_field->title);

 

 

Thanks @elabx, I tried, but in the source I am getting: 

	<p>Demo<span class="{strtolower(1->title)}">Management</span><</p>

I have included my foreach loop as well (if it helps)

<?php 
	$dash = $pages->get("/dashboard/");
	$dashchildren = $dash->children();
	$out = "";
	foreach($dashchildren as $dashchild){
		$out .= "<p>" . "<a href=\"{$dashchild->url}\">" . "{$dashchild->title}" . "</a>";
			foreach ($dashchild->children as $dashgrandchild) {
				$out .= "<span class=\"strtolower({$dashgrandchild->posistion->title})\">" . "{$dashgrandchild->title}" . "</span>";
			}
		$out .=  "</p>";
	}
	echo $out;
?>

 

Link to comment
Share on other sites

Something like this?

<?php 
	$dash = $pages->get("/dashboard/");
	$dashchildren = $dash->children();
	$out = "";
	foreach($dashchildren as $dashchild){
		$out .= "<p>" . "<a href=\"{$dashchild->url}\">" . "{$dashchild->title}" . "</a>";
			foreach ($dashchild->children as $dashgrandchild) {
              			$dashgrandchild_title = strtolower($dashgrandchild->posistion->title);
						$out .= "<span class=\"{$dashgrandchild_title}\">" . "{$dashgrandchild->title}" . "</span>";
			}
		$out .=  "</p>";
	}
	echo $out;
?>

 

  • 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...