I was trying to find a shorter way to write this if condition:
if($template == "documents"){
$slug = $template;
$parent = "products";
} else {
$slug = $slug;
$parent = $parent;
}
This is my approach:
$slug = ($template == "documents") ? $template : $slug;
$parent = ($template == "documents") ? "products" : $parent;
I have the feeling this code could be reduced more. But I do not know how.
Aucun commentaire:
Enregistrer un commentaire