Created
April 3, 2018 08:35
-
-
Save Firesphere/c0b08f82329d8fa1c18a4882e30e745a to your computer and use it in GitHub Desktop.
PersonaDemo
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 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