1<?php
2/**
3 * User blog widget display view
4 */
5
6/* @var $widget \ElggWidget */
7$widget = elgg_extract('entity', $vars);
8
9$num_display = (int) $widget->num_display ?: 4;
10
11$options = [
12	'type' => 'object',
13	'subtype' => 'blog',
14	'limit' => $num_display,
15	'pagination' => false,
16	'distinct' => false,
17];
18
19$owner = $widget->getOwnerEntity();
20if ($owner instanceof \ElggUser) {
21	$options['owner_guid'] = $owner->guid;
22} else {
23	$options['container_guid'] = $widget->owner_guid;
24}
25
26$content = elgg_list_entities($options);
27if (empty($content)) {
28	echo elgg_echo('blog:none');
29	return;
30}
31
32echo $content;
33
34if ($owner instanceof \ElggGroup) {
35	$url = elgg_generate_url('collection:object:blog:group', ['guid' => $owner->guid]);
36} else {
37	$url = elgg_generate_url('collection:object:blog:owner', ['username' => $owner->username]);
38}
39
40$more_link = elgg_view('output/url', [
41	'text' => elgg_echo('blog:moreblogs'),
42	'href' => $url,
43	'is_trusted' => true,
44]);
45echo elgg_format_element('div', ['class' => 'elgg-widget-more'], $more_link);
46