Skip to content

Instantly share code, notes, and snippets.

@Dinwid Dinwid/BuddiesListPage.php Secret

Last active Jul 17, 2020
Embed
What would you like to do?
<?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();
}
}
}
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
You can’t perform that action at this time.