Skip to main content
Topic: Spicing up mentions (Read 2441 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Spicing up mentions

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
Last Edit: June 06, 2014, 06:09:47 am by emanuele
Bugs creator.
Features destroyer.
Template killer.

Re: Spicing up mentions

Reply #1

Looks crowded and hard to read. Maybe a little separator in there or something? Cool idea though!
Success is not the result of spontaneous combustion, you must set yourself on fire!

Re: Spicing up mentions

Reply #2

It's not yet finished! ;D
Bugs creator.
Features destroyer.
Template killer.