Skip to content

Instantly share code, notes, and snippets.

@tonypartridge
Last active January 4, 2017 14:12
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tonypartridge/7f44087bce9562d7477bc276a716242b to your computer and use it in GitHub Desktop.
JEvents Latest Added Events Query / Setup
<p><?php echo JText::_("JEV_CPANEL_LATEST_EVENTS_ADDED_DESC"); ?> </p>
<?php
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.
$query
->select(array('evdet_id','dtstart', 'dtend', 'summary', 'modified', 've.ev_id', 've.created', 've.created_by', 've.state', 've.modified_by'))
->from($db->quoteName('#__jevents_vevdetail'))
->leftJoin($db->quoteName('#__jevents_vevent') . 'AS ve ON ve.detail_id = evdet_id')
->where($db->quoteName('ve.state') . ' = 1')
->order('ve.created ASC')
->setLimit($limit);
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$results = $db->loadObjectList();
if (count($results) > 0)
{
echo '<ul class="todo-list">';
foreach ($results as $row)
{
$user = JFactory::getUser($row->created_by);
echo '<li><span class="text">' . $row->summary . '</span>
<span class="label label-success"> ' . JText::sprintf("JEV_BY_SPRINT", $user->name) . '</span>
<div class="tools">
<a href="index.php?option=com_jevents&task=icalevent.edit&evid=' . $row->ev_id . '"><i class="fa fa-edit"></i></a>
<a href="index.php?option=com_jevents&task=icalevent.delete&evid=' . $row->ev_id . '"><i class="fa fa-trash-o"></i></a>
</div>
</li>';
}
echo '</ul>';
} else {
echo JText::_('JEV_CPANEL_LATEST_EVENTS_ADDED_NONE');
}?>
@brianteeman
Copy link

Either my data is corrupt (yikes I hope not) or

->leftJoin($db->quoteName('#__jevents_vevent') . 'AS ve ON ve.ev_id = evdet_id')

should be

->leftJoin($db->quoteName('#__jevents_vevent') . 'AS ve ON ve.detail_id = evdet_id')

@tonypartridge
Copy link
Author

tonypartridge commented Jan 4, 2017

@brianteeman No your completely right! I'll update it for future reference.

@brianteeman
Copy link

;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment