This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace AuthorPLugin\PLuginName\Components; | |
use Cms\Classes\ComponentBase; | |
use Lovata\Buddies\Models\User; | |
class BuddiesListPage extends ComponentBase | |
{ | |
public function componentDetails() | |
{ | |
return [ | |
'name' => 'BuddiesPage ', | |
'description' => '' | |
]; | |
} | |
public function defineProperties() | |
{ | |
return [ | |
'slug' => [ | |
'title' => 'Buddies slug', | |
'type' => 'string' | |
] | |
]; | |
} | |
public function onRun() | |
{ | |
$sElementID = $this->param('slug'); | |
if (empty($sElementID)) { | |
$this->page['arBuddiesList'] = User::all(); | |
} else { | |
$this->page['obBuddiesModel'] = User::where('id', (int) $sElementID)->first(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title = "BuddiesPage" | |
url = "/buddies/:slug?" | |
is_hidden = 0 | |
[BuddiesPage] | |
slug = ":slug" | |
== | |
{% if obBuddiesModel is not empty %} | |
{{ obBuddiesModel.email }} | |
{% else %} | |
{% for obBuddiesModel in arBuddiesList %} | |
{{ obBuddiesModel.email }} | |
{% endfor %} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment