Database Reference
In-Depth Information
Interest in Aggregate
Inside the
/interest
route, we retrieve all of the user's tags and their friends tags by calling, respectively, the
userTags
and
tagsInNetwork
methods found in the
Tag
class. This is displayed in the left-hand column ikn Figure
8-12
.
Figure 8-12.
Filtering the current user's content
The display code is located in
{PROJECTROOT}/ app/templates/graphs/interest/index.mustache.
The
interest
route uses two queries, which are shown in Listing 8-35 and 8-36. The
getFollowingContentWithTag
finds
users being followed, accesses all of their content, and finds connected tags through the
HAS
relationship type.
The
getUserContentWithTag
method is similar, but is concerned only with content and, subsequently, tags
connected to the current user. Both methods limit the results to 30 items. As mentioned earlier, the methods return an
array of content and tags, which supports an autosuggest plugin in the view and requires both a label and name to be
provided in order to execute. This autosuggest feature is used in the status update form as well as some search forms
found later in this chapter.
Listing 8-34.
The
interest
Route
# show tags within the user's network (theirs and those being followed)
$app->get('/interest', $isLoggedIn, function () use ($app) {
# get the user's tags
$userTags = Tag::userTags($_SESSION['username']);
# get the tags of user's friends
$tagsInNetwork=Tag::tagsInNetwork($_SESSION['username']);
$contents = null;
$userscontent = $app->request()->get('userscontent');