$label = 'label';
if ($user->language->title != 'no') {
$label = "label{$user->language}";
}
echo $page->fields->get('phone')->$label;
The above code works great on a regular php page, but I can´t get it to work inside a function - yes, yes - newbie
function renderAuthorData($page) {
$na = "<span class='na'>n/a</span>";
$download = $page->files->first()->name;
//Check if author is an employee
$vista = $page->vista;
if($vista == 1){
$label = 'label';
if ($user->language->title != 'no') {
$label = "label{$user->language}";
}
$out = "\n<table class='publication_data'>" .
"\n\t<tbody>";
//Check if author has a specific function
if($page->function){
$out .= "\n\t<tr><th>". ($page->fields->get('function')->$label) ."</th><td>". ($page->function ? $page->function : $na) . "</td></tr>";
}
$out .= "\n\t<tr><th>". ($page->fields->get('author_title')->$label) ."</th><td>" . ($page->author_title ? : $na) . "</td></tr>" .
"\n\t<tr><th>". ($page->fields->get('phone')->$label) ."</th><td>" . ($page->phone ? : $na) . "</td></tr>" .
"\n\t<tr><th>". ($page->fields->get('author_email')->$label) ."</th><td>" . ($page->author_email ? : $na) . "</td></tr>" .
"\n\t<tr><th>". ($page->fields->get('address')->$label) ."</th><td>" . ($page->address ? : $na) . "</td></tr>" .
"\n\t<tr><th>CV</th><td><a href='{$page->files->first()->url}'>" . $download . "</a> ({$page->files->first()->filesizeStr})</td></tr>" .
"\n\t</tbody>" .
"\n</table>";
}else if($vista == 0){
$out = "\n\t<div style='clear:both;'><p>{$page->title} er ikke ansatt i Vista Analyse AS, men er medforfatter på følgende publikasjon(er):</p></div>";
}
return $out;
}
It would be great to check for $user->language from inside a function. Can anyone help me with this? Probably very easy for someone with more PHP knowledge than me....
(The slightly modified code is from Ryan´s Skyscraper Profile - I have spent a few hours "dissecting" that profile to make a site for client - will share next week in the forum)