Ok so I tested this myself, works pretty good. Heres a better pasted version:
<?php
$name = $thisstaff->getName();
$user = "John Doe";
$user2 = "Jane Smith";
?>
<textarea name="answer" cols="22" rows="12" style="width%;" class="richtext draft" data-draft-namespace="faq" data-draft-object-id="<?php if (is_object($faq)) echo $faq->getId(); ?>">
<?php
$textarea = $info;
echo $info;
?>
<?php
if ($name == $user){
$job="IT Support";}
elseif($name == $user1){
$job="Operations";}
else {$job="";}
?>
<?php $todayte = date('d/m/y/')?>
<?php if ($textarea == "") {
echo "<span style='color(0,0,0);'><strong><em><strong>Author: $name <br> Position: $job <br> Date: $todayte</strong><br></em></strong><br></span><span></span>";}
else {
echo "<span style='color(0,0,0);'><strong><em><strong>Updated by: $name <br> Updated on: $todayte</strong></em></strong></span><br><br>";}
?>
</textarea>
So I thought instead of doing an
if
check using the $name variable to see what $job or 'position' the user is to use the following:
$job = thisstaff->getDepartments();
However when I tested this, the output is always "Array" and I'm not sure why.
Also, when the updated 'echo' occurs, I always get "Array" before "Updated by: $name" etc.
I think this has something to do with
$textarea = $info;
because at the top of 'faq.inc.php' we have another variable that is like so:
$info = $qs = array();
However, I'm not a big PHP expert, so I wouldn't know how to fix this issue.
Regardless, i just removed the job portions as all I really needed was the user and date information, and those work.
Apart from the random 'Array' echo appearing before "Updated by:" this works damn well.
I stuck this code on line 193, right after </textarea>.
Hope that helps and hope a dev or someone better at PHP can explain why the "Arrays" show up instead of the Department name, and why theres an "Array" string before "Updated by:".
!! EDIT !!
This is the final code I'm using:
<?php
$name = $thisstaff->getName();
?>
<textarea name="answer" cols="22" rows="12" style="width%;" class="richtext draft" data-draft-namespace="faq" data-draft-object-id="<?php if (is_object($faq)) echo $
<?php
$textarea = $info;
echo $info;
?>
<?php
$todayte = date('m/d/y/');
?>
<?php if ($textarea == "") {
echo "<span style='color(0,0,0);'><strong><em><strong>Author: $name <br> Date: $todayte</strong><br></em></strong><br></span><span></span>";
}
else {
echo "<span style='color(0,0,0);'><strong><em><strong>Updated by: $name <br> Updated on: $todayte</strong><br></em></strong><br></span><span></span><br>";
}
?>
</textarea>
However the issue I'm encountering now is that on a brand new FAQ it populated with "Updated by:" when it shouldn't according to this 'if' check:
<?php if ($textarea == "") {
This should check the textarea and see if its blank, correct? And if so it then says:
if blank, echo "Author: $name" etc.
ELSE echo "Updated by:"
So I'm confused why its not detecting that the textarea is blank. Does anyone have a better idea on how to detect if the 'textarea' is blank?