TheBigK
Well-known member
I'm currently referring to this tutorial: https://xenforo.com/community/resou...rofile-page-using-hooks.335/update?update=487
I could follow the entire tutorial until I stumbled upon this code snippet from the tutorial. My questions are very basic:-
1. How would a new programmer know that I need to use functions / arrays such as -
Is there any pattern I need to know? I found out that the code snippet has been taken from /library/XenForo/ControllerPublic/Member.php --->>actionFollowers().
2. getModelFromCache : Why has this been used? And how would I know that I need to use getModelFromCache and not something else?
PHP:
<?php
class newProfileTabs_Extend_ControllerPublic_Member extends XFCP_newProfileTabs_Extend_ControllerPublic_Member
{
//See? actionNameOfOurAction
public function actionUsersLike()
{
//Lets get the userID
$userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
$user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId);
//Lets get all the likes that this user gave to anothers
//We are using our function here and our model! getAllGivenLikesByUser()
$users_likes = $this->getModelFromCache('newProfileTabs_Model_newProfileModel')->getAllGivenLikesByUser($userId, '10');
//Returning all the values to our template newProfileTab_ourTab_content
//With the variable $users_likes, and the variable $user.
return $this->responseView(
'newProfileTab_ViewPublic_Member_UsersLike', 'newProfileTab_ourTab_content',
array('user' => $user, 'users_likes' => $users_likes)
);
}
}
?>
I could follow the entire tutorial until I stumbled upon this code snippet from the tutorial. My questions are very basic:-
1. How would a new programmer know that I need to use functions / arrays such as -
Code:
$userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);$user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId);
Is there any pattern I need to know? I found out that the code snippet has been taken from /library/XenForo/ControllerPublic/Member.php --->>actionFollowers().
2. getModelFromCache : Why has this been used? And how would I know that I need to use getModelFromCache and not something else?