0

I have created a view displaying a user's blog entries. In view's empty text i have put the simple php code showing below

You have not created any blog entries.

You can create a Now i want to modify it to implement the following scenario. 1. When a user visit his/her profile page the above empty text should be appear. 2. If a user visit an another user profile page then i want the empty text to have the following value [username of the user that own's the profile page] hasn't created any blog entries. Can anyone help me to achieve this? Thanks in advance.

2

Do you have the php filter input format turned on for your site? You can do this by adding the following code into your empty text field with the input format 'php code' enabled:

//get the current $user object to determine the logged in user's id
global $user;  

//now load the user id from the profile page into another object by pulling it from path
$usertmp = user_load(array('uid' => arg(1)));

if ($user->uid == $usertmp->uid) {
     //we're on the logged in user's page
     print "You need to write more stories..";
} else {
     print $usertmp->name." needs to write more stories.. ";
}
  • Thank you very much for your help. I came up with script. It isn't elegant since i started now to learn php but it get the job done. – Pavlos Dec 30 '11 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.