Skip to content

Instantly share code, notes, and snippets.

@Dinwid
Last active July 17, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dinwid/bb61b3d1a3957c6afda7fb6b0611e471 to your computer and use it in GitHub Desktop.
Save Dinwid/bb61b3d1a3957c6afda7fb6b0611e471 to your computer and use it in GitHub Desktop.
<?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