ElkArte Community

General => Site Feedback => Topic started by: emanuele on June 05, 2014, 07:18:08 pm

Title: Spicing up mentions
Post by: emanuele on June 05, 2014, 07:18:08 pm
That's something that will likely end up in an addon, though it's just something I put together this afternoon to see how features can be "tweaked".

The droppy is generated by a jQuery plusing (I created a plugin because it may be used for other things as well :P).

But the nicest thing (at least for me), is how the server-side code is handled.
In order to populate the droppy I needed to grab the mentions, so I decided to try to use any possible existing function, and I was able to to everything with just that code:
Code: [Select]
<?php

if (!defined('ELK'))
die('No access...');

require_once(CONTROLLERDIR . '/Mentions.controller.php');

class Mentions_ajax_Controller extends Mentions_Controller
{
public function action_list()
{
global $context;

parent::action_list();

$context['sub_template'] = 'json_mentions';
}

public function list_loadMentions($start, $limit, $sort, $all, $type)
{
global $context;

$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 5;
$limit = !empty($limit) ? $limit : 5;

$mentions = parent::list_loadMentions(0, $limit, $sort, true, $type);
foreach ($mentions as $id => $mention)
$context['json_data'][] = array(
'status' => $context['mentions_ajax'][$id],
'member' => $value['data']['id_member_from']['value'],
'message' => $value['data']['type']['value'],
'logtime' => $value['data']['log_time']['value'],
);
return $mentions;

}
}

About 40 lines of php in total.
Code reuse FTW!! :D
Title: Re: Spicing up mentions
Post by: IchBin on June 05, 2014, 10:12:34 pm
Looks crowded and hard to read. Maybe a little separator in there or something? Cool idea though!
Title: Re: Spicing up mentions
Post by: emanuele on June 06, 2014, 03:01:19 am
It's not yet finished! ;D