Skip to content

Instantly share code, notes, and snippets.

@Firesphere
Created April 3, 2018 08:35
Show Gist options
  • Save Firesphere/c0b08f82329d8fa1c18a4882e30e745a to your computer and use it in GitHub Desktop.
Save Firesphere/c0b08f82329d8fa1c18a4882e30e745a to your computer and use it in GitHub Desktop.
PersonaDemo
<?php
namespace Firesphere\Persona\Elements;
use All\The\Persona\things;
class PersonaElement extends ElementContent
{
private static $has_one = [
'Persona' => Persona::class
];
public function getShowForPersona()
{
$visitor = Visitor::get()->byProfile('VisitorProfile')->first();
if ($visitor->PersonaID === $this->Persona()->ID) {
return true;
}
return $this->Persona()->Title === 'generic' ?: false;
}
}
class Persona extends DataObject
{
private static $db = [
'PersonaProfileThings' => 'Varchar(255)'
];
private static $has_many = [
'Visitors' => Visitor::class
];
}
class Visitor extends DataObject
{
private static $db = [
'PersonaStuff' => 'Text'
];
private static $has_one = [
'Persona' => Persona::class,
];
}
-----
Template
-----
<% if $ShowForPersona %>
MyContentHere
<% end_if %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment