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

jerry3850
jerry3850

I noticed in the version.yaml file for the RainLab Blog plugin that in version 1.0.5 the Author column was removed from the blog post list. Does anyone know why this was done and how I can add the blog author back in? I notice that there is a user_id field (I assume for the author) that is set to null in the rainlab_blog_posts table.

Last updated

jerry3850
jerry3850
jerry3850

If nobody can help me with my original question, can somebody at least tell me where in the RainLab Blog plugin is the post data being saved to the rainlab_blog_posts table. I have looked in each of the files and it isn't obvious to me. Any help would be appreciated.

Last updated

AndreiCurelaru
AndreiCurelaru

Hi Jerry, I first installed October yesterday and diving into it since that, i'll take a look at that author/yaml thing. Thanks for pointing it out.

eidsza8718
eidsza8718

Hi, if You want to access user data, just add "key" value to relations: public $belongsTo = [ 'user' => ['Backend\Models\User','key'=>'user_id'] ]; and then {{ post.user.first_name}} or any other user table column like {{ post.user.last_name}}

that's All

Last updated

Goedda
Goedda

Interesting that a {{ dump() }} does not reveal the user information easily. But you can use {{ dump(post.user} }} or {{ post.user }} to reveal the information.

And for all beginners (as I am): The 'key' is optional. The user data is available even without the key. The key can be used as an argument like sorting or couting, but adding an argument in the core plugin file would then be also hacking the core plugin.

pouria
pouria

Goedda said:

Interesting that a {{ dump() }} does not reveal the user information easily. But you can use {{ dump(post.user} }} or {{ post.user }} to reveal the information.

And for all beginners (as I am): The 'key' is optional. The user data is available even without the key. The key can be used as an argument like sorting or couting, but adding an argument in the core plugin file would then be also hacking the core plugin.

i was wondering if there is a way to access the user's image (vector) in blog plugin's frontend?

Last updated

ribbsousa
ribbsousa

dump data:

{{ post.user.avatar }}

print avatar data:

<img src="{{ post.user.avatar.path }}" alt="{{ post.user.avatar.file_name }}"/>
mrdavelee201219495
mrdavelee201219495

You can just use {{ post.user.first_name }} {{ post.user.last_name }}

driss.chelouati27209
driss.chelouati27209

Hello, iam reviving this old topic because i cant print post user related data. >ribbsousa said:

dump data:

{{ post.user.avatar }}

print avatar data:

<img src="{{ post.user.avatar.path }}" alt="{{ post.user.avatar.file_name }}"/>

this does not work in my environment. Any advice on how i can achieve that ?

ribbsousa
ribbsousa

Make sure you've added the Post component on your page to view the post, do not put the componet in the partial.

Remembering that this is only going to show the user image data

{{ post.user.avatar }}

if you want to show other insinuations you need to use this

{{ post.user }}

Last updated

driss.chelouati27209
driss.chelouati27209

{"id":1,"first_name":"admin","last_name":"admin","login":"admin","email":"driss.chelouati@gmail.com","permissions":"","is_activated":true,"role_id":2,"activated_at":null,"last_login":"2017-12-24 01:50:48","created_at":"2017-12-24 01:50:36","updated_at":"2017-12-24 01:50:48","is_superuser":1,"avatar":null}

this is the dump that i get, thank you for your answer, i just understood that iam damn stupid. The dump shows "null" for the post avatar because i didnt upload one for my admin account. So damn stupid now it works. Thanks a lot for pointing out this.

kutup
kutup

Firt Name: {{ post.user.first_name }} Sur Name: {{ post.user.last_name }} it's working.

subdesu
subdesu

Just in case someone is wondering how to get the post author username instead of first name and last name like I was, then they can try this code, {{ post.user.login }} .

That worked for me.

zoltan.birner36658
zoltan.birner36658
Object variables
NULL

It doesn't work at all, there is no post.user object anymore

Last updated

jopeme201964314
jopeme201964314

I actually managed to use the first and last name code. But I wanna be able to change in between authors as it'll be more than author, and so far nothing. Has anyone managed to get the right code?

jopeme201964314

1-17 of 17

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