public function getModelEventsData($categoryId = null, $limit = null)
{
- //echo '<pre>categoryId: ' . print_r( $categoryId, true ) . '</pre>';
- //echo '<pre>limit: ' . print_r( $limit, true ) . '</pre>';
if ($categoryId) {
return $this->getEventsByCategory( $categoryId, $limit );
} else {
public function getModelEventData($eventId)
{
- $events = $this->getModelEventsData();
- return array_filter($events, function($data) use($eventId) {
- return $data['id'] == $eventId;
- });
+ return $this->getEntry($eventId);
}
/**
if ($eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) {
$search = true;
$action = 'event-detail';
+ } else {
+ $search = true;
+ $action = 'event-detail';
+ $eventslug = get_query_var( 'eventslug' );
+ $sql = "
+ SELECT id
+ FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "events
+ WHERE name_slug = '$eventslug'";
+ $eventId = $this->wpdb->get_var($sql);
}
$categories = $this->getCategories();
switch ($action) {
case 'event-detail':
- $events = $this->getModelEventData($eventId);
- $events = array_values($events);
- $event = $events[0];
+ $event = $this->getModelEventData($eventId);
$view = 'detail.html';
break;
default:
$view = 'dashboard.html';
foreach ( $categories as $catid => $catData ) {
$catEvents = $this->getModelEventsData( $catid, 3 );
- //echo '<pre>' . print_r( $catEvents, true ) . '</pre>';
if ( !empty($catEvents) ) {
$categoryEvents[$catid] = $catEvents;
}
// Setup rewrite for member detail pages
add_filter('rewrite_rules_array', function($rules) {
$newrules = array();
- $newrules['('.$this->config['settings']['canonical_event_page'].')/([^/]*)$'] = 'index.php?pagename=$matches[1]&eventId=$matches[2]';
+ $newrules['('.$this->config['settings']['canonical_event_page'].')/([^/]*)$'] = 'index.php?pagename=$matches[1]&eventslug=$matches[2]';
return $newrules + $rules;
});
-// Add eventId query var
+// Add eventslug query var
add_filter('query_vars', function($vars) {
- array_push($vars, 'eventId');
+ array_push($vars, 'eventslug');
return $vars;
});
{/if}
<li class="description text-left">
{$event.starting_date|date_format}<br>
- <a href="{$siteBaseUrl}event-detail/{$event.slug}">
+ <a href="{$siteBaseUrl}event-detail/{$event.name_slug}/">
{$event.name}
</a>
</li>
</div>
<div class="row">
<div class="small-12 column">
- <h1>{$event.title}</h1>
+ <h1>{$event.name}</h1>
</div>
<div class="small-12 column">
<img style="margin: 15px;" src="http://placehold.it/730x280">