This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

LMBdev
LMBdev

First time posting here. New to october. I've done an extensive search to try and figure out how to solve my problem of displaying user properties for the User plugin.

I've referenced several pages: https://octobercms.com/docs/markup/tag-for https://octobercms.com/docs/plugin/components https://octobercms/docs/backend/users

I've got a basic page setup with the User account component. Here's the code:

Users:

      {% for key in user %}
    • {{ key }}: {{ user.key }}
    • {% endfor %}

Total users: {{ user.count() }}


I'm getting an output for the total users, but no other values.

What I'm trying to do is create a profile page for each user that can be viewed by visitors. So I'd like to page to look something like this:

Name: User Example Email: user@example.com Title: Rockstar . . . etc.

Any assistance is appreciated. Thanks.

-Larry

RedMarlin
RedMarlin

I think you should iterate over keys and values this way:

{% for key, value in user %}
{{ key }}: {{ value.key }}
LMBdev
LMBdev

Thanks for the reply. I tried this and its still not showing anything. The only output im getting is the first line and the count.

Code: Users:

      {% for key, value in user %} {{ key }}: {{ key.value }} {% endfor %}

Total users: {{ user.count() }}

Do I need anything in the code portion of the page? I've got the account component added to the page of course but nothing else.

RedMarlin
RedMarlin

Could you explain again what are you trying to achieve? Do you want to show details for one logged in user?

RedMarlin
RedMarlin

Could you explain again what are you trying to achieve? Do you want to show details for one logged in user?

LMBdev
LMBdev

Yes that's exactly what I'm hoping to achieve. Why it's proving to be more challenging than I thought, not sure.

I mean I can access the user array with {{ user }}. For instance:

{{ user }}

Output:

Users: {"id":2,"name":"User Example","email":"user@example.com","permissions":null,"is_activated":true,"activated_at":"2017-06-02 13:42:58","last_login":"2017-06-02 13:43:29","created_at":"2017-06-02 13:41:56","updated_at":"2017-06-02 13:51:35","username":"user@example.com","surname":"","deleted_at":null,"last_seen":"2017-06-02 13:49:27","is_guest":0,"is_superuser":0} Total users: 2

So what I'm trying to do is iterate through each key and output the value without having to go through and do something like {{ user.name}} {{ user.email}} . . etc.

Thanks for the quick reply.

RedMarlin
RedMarlin

Ah OK, sorry I misunderstood it at the begging, I though you were iterating over array of various users.

You cant iterate on keys of a single user this way.

Last updated

LMBdev
LMBdev

Is there anyway to accomplish what I'm wanting to do then?

1-8 of 8

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.