Notice

The forum is in read only mode.

Support Forum

Welcome! Support Forums have been reactivated
Welcome the Technical Support section. Help us in assisting you by providing us with a concise and descriptive elaboration of your issues. Be specific and if possible, provide us with a step-by-step instruction in replicating your problem.

Get username variable in profile.index.php

9 years 4 months ago
  • marija's Avatar
    Topic Author
  • marija
  • Offline
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 1
Licenses:
JomSocial Expired Socialize Expired

Hi, I am adding some custom elements to profile.index.php, and I need to show the username.

This is possible in userinfo.php with
<?php echo $user->getDisplayName(); ?>

but when I try that in profile.index.php it breaks the page.

How can I display the name?

Thanks and Happy Holidays!

9 years 4 months ago
  • Paul's Avatar
  • Paul
  • Visitor
  • Thank you received: 0
Licenses:

Hi Marija,

I think you are just not getting the user object yet. Have a look at this page is has a lot of examples and explains some of the different methods available. documentation.jomsocial.com/wiki/JomSocial_User_Object

I hope this helps

9 years 4 months ago
  • marija's Avatar
    Topic Author
  • marija
  • Offline
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 1
Licenses:
JomSocial Expired Socialize Expired

Paul, unfortunately that did not clear the issue.
Placing
$cuser = CFactory::getUser();
$data = $cuser->getDisplayName();
echo $data;

in profile.index.php returns the username of the logged in user. I need to show the username of the person who's profile is being viewed.

The purpose of this, is to add simple heading saying "Username's Wall"

9 years 4 months ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

Hi Marija,

Please you use this :

$cuser = CFactory::getUser();
echo $cuser->username;

I hope it will work

9 years 4 months ago
  • marija's Avatar
    Topic Author
  • marija
  • Offline
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 1
Licenses:
JomSocial Expired Socialize Expired

Dimas, this as well returns the username of the person looking at the website, ex. Guest, or Me... etc.. I need the username of the profile being viewed, do you understand? Please see screenshot for explanation

Attachment Untitled12.png not found

Attachments:
9 years 4 months ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

May I know in which page position do you want to show it? I will give you the full code

9 years 4 months ago
  • marija's Avatar
    Topic Author
  • marija
  • Offline
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 1
Licenses:
JomSocial Expired Socialize Expired

As said in the previous replies, I am editing in profile.index.php

What position do you need?

9 years 4 months ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

Your screenshoot is not coming from Jomsocial code, I am sure its coming from 3rd party app... your backend is not working so I can test it..

well, you should add the userid paramater on creating Cuser Object :

$cuser = CFactory::getUser(USERID);
echo $cuser->username;

actually, if you want to show username globally you can set it from Jomsocial configuration->layout->Display Name change to username

I hope it will help.

Best

9 years 4 months ago
  • marija's Avatar
    Topic Author
  • marija
  • Offline
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 1
Licenses:
JomSocial Expired Socialize Expired

Dimas, that does not help at all and I am getting a little tired from your approach and effort. Now, this is the last time I am asking kindly, as it has been over two weeks since I first asked a simple question.

I will not explain the question again, as you can just scroll up and see.

The screenshot is coming from JomSocial, and shame on you for not recognizing it. I have just modified the layout of the profile page. You do not need the backend at all, as I have mentioned in the previous post, I am editing in /templates/socialize/html/com_community/profile.index.php, line 88

FTP is provided in the first post, and it is working, the site is under the /nomad subfolder.

I will find the patience to wait out for one more of your replies, make it worth.

9 years 4 months ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

Hi Marija,

With all respect, i see this screenshoot www.jomsocial.com/media/kunena/attachmen...36415/Untitled12.png is NOT coming from Jomsocial, and we dont have "reviewed" text/stream by default on profile.index.php page.. so thats why i want to know where you get this? so I need the backend access..

thank you for your patient

note : if you have limited skill on PHP, it will hard to understand what I said on here www.jomsocial.com/forum/profile-universa...ile-index-php#114710

9 years 4 months ago
  • marija's Avatar
    Topic Author
  • marija
  • Offline
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 1
Licenses:
JomSocial Expired Socialize Expired

Dimas, that is not all respectful.

First of all, JomSocial is marketed as EXTENDABLE, so I have extended it with jReviews. The WALL streams are PURELY from JomSocial, the fact that you are confused by the 'reviewed' word is quite embarrassing for a team of the JomSocial development!

I CLEARLY understand what you said, but, once again, it displays the username of the person LOGED IN. Now, do you understand me?

Please be kind and assign this to someone who is not as as lost in their job as you are.

Apologies for being rude, but you do need to try harder.

9 years 4 months ago
  • Dimas Tekad Santosa's Avatar
  • Dimas Tekad Santosa
  • Visitor
  • Thank you received: 0
Licenses:

OK let me clarify this, on last code you didnt provide the userid of your viewed user, I will give you the detail code, please try this :

$cuser = CFactory::getUser($userid);
						echo $cuser->username;
						// or you can use
						echo $cuser->getDisplayName();

and you should send the paramater of $userid from this file components/com_community/views/profile/view.html.php, add this code :
->set('userid',$user->id)

before this code
->fetch('profile.index');

9 years 4 months ago
Licenses:

Hi, Marija.

Code provide by Dimas works but maybe you'll find this one a bit more simple. Just paste this code wherever you want to display user name in profile.index.php:

$cuser = CFactory::getUser(JRequest::getCmd(userid));
echo $cuser->name;

As you can see this is nearly exact Dimas code except that "USERID" is replaced by code fetching id directly "JRequest::getCmd(userid)".

I tested this solution and it works 100%.


- Instead of saying: 'it's not working', explain the problem in detail.
- Screenshots with the URL visible in them and the problem marked are more than welcome.
- Tell us how to replicate the problem, we can't fix it if we can't find it.
- Make sure that your site/server meets JomSocial System Requirements
- Make sure to setup JomSocial Cron Job
- Always provide us with access details to the backend and ftp. We need it to debug problems.
- If you have a similar problem, but a solution you found isn't working, open a new thread instead of 'merging' with an existing one.

- Use the "Thank You" feature on any post that helped you
9 years 4 months ago
  • marija's Avatar
    Topic Author
  • marija
  • Offline
  • Fresh Boarder
  • Posts: 22
  • Thank you received: 1
Licenses:
JomSocial Expired Socialize Expired

Michal, thank you - I can confirm that is correct.

I apologize for my rudeness towards your employee, I know I was not asking something that counts as 'support', but it is a very needed line of code, I was expecting him to know it from the top of his head, but what frustrated me more is that he did not test or try to understand the issue.

Never mind, I appreciate your contribution, have a lovely day!

Moderators: Piotr Garasiński
Powered by Kunena Forum

Join 180,000 websites creating Amazing communities

JomSocial is the most complete, easy-to-use addon that turns Joomla CMS into a
full -fledged, social networking site

TRY NOW BUY NOW