Why don’t you use a relation between category and article?
In Article.php (model)
// I use categoryRelation name because category has been used to identify category id ( I would have used category_id )
public function getCategoryRelation()
// Customer has_many Order via Order.customer_id -> id
return $this->hasOne(Category::className(), ['category' => 'id']);
Then in your view you can access to category name from article in this way:
No I am not to sure how to pass the id/parameter to the getCategoryName function in my model, is this something I should do in my controller and then pass to view or is it something I should put in my view.
For example this
<?= $model->CategoryName ?>
in my view displays sport as no category/id is being passed to the function.