8 years ago
Topic

Hi everyone,

I need a help.

Can you tell me how to display inside an article the current user name (i.e. first name) inside an article ? I found nowhere inside the forum something that explain the way to do it.

Thanks for your contribution.

Get a VIP membership
4229 Posts
Kadministrator
8 years ago
0
Level 1

You could place some tag like #display_username# in your text, then use code pack beforeRender plugin and use php to replace this tag with users name.

8 years ago
2
Level 1

Thank you Klas for your reply. I just bought the code pack and tested it.
When you say to use a TAG as #display_username# in my text, do you mean that I have to use the fieldname between # or am I mistake ?

What I did :

1) Created a new field in my content type called Display Username (display_username), filled it with my php code 

$user = JFactory::getUser(); if (!$user->guest) { echo $user->username . ", "; } else { echo "Hey !"; (witch works outside Seblod)

I tried it with and without <php> tags.

2) In my content, I added #display_username#

3) When I try to display the content, it gives me #display_username# and not the username.

What did I wrong Klas ?

Thank you

4229 Posts
Kadministrator
8 years ago
1
Level 2

I wrote Using Code Pack tutorial with this example

8 years ago
0
Level 3

Hi Klas,

Thank you for the tutorial. It will be usefull for some other jobs.

Maybe my request wasn't clear. What I want is to put inside an article (in the text) the username or the first name for example. I thought that Seblod will parse the tag that you mentioned above #display_username# and will replace it by the field created by 'beforeRender plugin' (witch retrieve the username with a php code in my case).

Could you be more explicit concerning the method to achieve this task ?

Regards

8 years ago
0
Level 1

Dear Klas,

Forget the previous post. I misunderstood your previous message. I'm new in Seblod spirit and it took me some time to apprehend the logic.

All works fine now ! 

Thanks again for your efficiency !

Get a VIP membership