Last active
August 29, 2015 14:06
-
-
Save jedateach/a13928f1032fe0df8825 to your computer and use it in GitHub Desktop.
Shortcodable Dev
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 | |
class OverviewLink extends ViewableData implements Shortcodable { | |
protected $data = array( | |
'Title' => null, | |
'Content' => null, | |
'LinkLabel' => 'Find out more' | |
); | |
public static function parse_shortcode($arguments, $content, $parser, $shortcode) { | |
$link = new OverviewLink(); | |
$link->setData($arguments); | |
return $link->renderWith("OverviewLink"); | |
} | |
public static function shortcode_attribute_fields(){ | |
return FieldList::create( | |
UploadField::create('ImageID','Image'), | |
TextField::create("Title"), | |
HTMLEditorField::create("Content"), | |
LinkFormField::create("Link"), | |
TextField::create("LinkLabel","Text on link") | |
); | |
} | |
public function singular_name() { | |
return "Overview Link"; | |
} | |
function Image(){ | |
if(isset($this->data['ImageID[Files][]'])){ | |
return Image::get()->byId((int)$this->data['ImageID[Files][]']); | |
} | |
} | |
function Title(){ | |
return $this->data['Title']; | |
} | |
function Content(){ | |
return $this->data['Content']; | |
} | |
function Link(){ | |
if(isset($this->data["Link[CustomURL]"])){ | |
return $this->data["Link[CustomURL]"]; | |
}elseif(isset($this->data["Link[PageID]"])){ | |
return Page::get() | |
->byID((int)$this->data["Link[PageID]"]) | |
->Link(); | |
} | |
} | |
function LinkLabel(){ | |
return $this->data['LinkLabel']; | |
} | |
function setData($data){ | |
$this->data = array_merge($this->data, $data); | |
} | |
} |
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
<div class="overviewblock"> | |
<% if Image %> | |
<div class="overviewblock_image"> | |
$Image.SetRatioSize(375,265) | |
<div class="overviewblock_image_fade"></div> | |
</div> | |
<% end_if %> | |
<div class="overviewblock_content"> | |
<h2 class="overviewblock_title">$Title</h2> | |
<div> | |
$Content | |
</div> | |
<p> | |
<a href="$Link" class="btn btn-success btn-lg btn-angled"> | |
$LinkLabel | |
</a> | |
</p> | |
</div> | |
</div> |
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
[OverviewLink ImageID[Files][]="82" Title="Business After 5" Content="A chamber run programme for businesses wishing to promote themselves or host an event. | |
When: always" Link[PageID]="38" LinkLabel="Find Out More"][OverviewLink ImageID[Files][]="81" Title="Business After Five" Content="A Chamber run programmer for businesses wishing to promote themselves or host an event.When: Last Wesnesday of each month, bi-monthlyVenue: Member hostedTime: 5.30pm to 7pmx" Link[PageID]="3" LinkLabel="Click here"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment