This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi I am an absolute beginner,
I created a private plugin (using builder) using which i can add an upcoming event and also speaker of the event in backed. Now I want to list out all the events in the front end. So I used Record List component to list out all the event and used Record Details component to view a single component.
But I want to create seperate components for my plugin, one to view all the events and another to view event details in front end.
I tried creating a component to view all the events and it worked but i can't click on it to go to the event page.
It will be great if you can help me to set up that component.
Thanks a lot!
My codes are below:
List all - component:
<?php namespace Dijo\Events\Components;
use BackendAuth;
use Cms\Classes\Page;
use Cms\Classes\ComponentBase;
use Dijo\Events\Models\Event;
use Dijo\Events\Models\Speaker;
class Events extends ComponentBase
{
/**
* Collection of the portfolio items to display
*
* @var Collection
*/
public $event;
/**
* Reference to the item page to link items to
*
* @var String
*/
public $eventPage;
public function componentDetails()
{
return [
'name' => 'Events List',
'description' => 'Displays the list of events',
];
}
public function defineProperties()
{
return [
'order' => [
'title' => 'Order',
'placeholder' => 'Select Order',
'type' => 'dropdown',
'default' => 'asc',
],
'eventPage' => [
'title' => 'Event Page',
'type' => 'dropdown',
'default' => 'contact',
],
];
}
'desc' => 'Descending'
/**
* Get options for the order dropdown
*
* @return array
*/
public function getOrderOptions()
{
return [
'asc' => 'Ascending',
];
}
/**
* Get options for the dropdown where the link to the item page can be selected
*
* @return mixed
*/
public function getEventPageOptions()
{
return Page::sortBy('baseFileName')->lists('baseFileName', 'baseFileName');
}
/**
* Injecting Assets
*/
public function onRun()
{
$this->events = $this->loadEvents();
}
protected function loadEvents(){
return Event::all();
}
public $events;
}
default.htm :
{% set events = __SELF__.events %}
{% for event in events %}
{{ event.title }}
{{ event.speakers.speaker_name }}
{{ event.speakers.speaker_profile.path }}
{{ event.short_img.path}}
{% endfor %}
1-1 of 1