Skip to content

Commit

Permalink
Dev: added class variable cache for getPreview
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Aug 14, 2017
1 parent fa9af66 commit abaff30
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions application/models/TemplateConfiguration.php
Expand Up @@ -47,6 +47,10 @@ class TemplateConfiguration extends TemplateConfig
*/
public $oParentTemplate;

/** @var string $sPreviewImgTag the template preview image tag for the template list*/
public $sPreviewImgTag;


/**
* @return string the associated database table name
*/
Expand Down Expand Up @@ -157,8 +161,11 @@ public static function model($className=__CLASS__)
// For list, so no "setConfiguration" before
public function getPreview()
{
$previewUrl = Template::getTemplateURL($this->template->name);
return '<img src="'.$previewUrl.'/preview.png" alt="template preview" height="200"/>';
if (empty($this->sPreviewImgTag)){
$previewUrl = Template::getTemplateURL($this->template->name);
$this->sPreviewImgTag = '<img src="'.$previewUrl.'/preview.png" alt="template preview" height="200"/>';
}
return $this->sPreviewImgTag;
}

/**
Expand Down

0 comments on commit abaff30

Please sign in to comment.