Skip to content

Commit

Permalink
show image only if entity has one
Browse files Browse the repository at this point in the history
  • Loading branch information
Praesidiarius committed Jan 28, 2020
1 parent 9d7455c commit 5e275fc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions module/Application/src/Model/CoreEntityModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ class CoreEntityModel {
*/
protected $sSingleForm;

public $created_by;

public $created_date;

public $modified_by;

public $modified_date;

/**
* CoreEntityModel constructor.
* @param AdapterInterface $oDbAdapter
Expand Down Expand Up @@ -256,6 +264,7 @@ protected function attachDynamicFields() {
case 'text':
case 'textarea':
case 'email':
case 'featuredimage':
case 'tel':
$this->$sFieldName = '';
break;
Expand Down Expand Up @@ -289,4 +298,18 @@ protected function updateDynamicFields(array $aData) {
}
}
}

/**
* Checks if Entity has featured image
*
* @return bool true if has, false otherwise
* @since 1.0.5
*/
public function hasFeaturedImage() {
if(property_exists($this,'featured_image')) {
return true;
} else {
return false;
}
}
}
4 changes: 4 additions & 0 deletions module/Application/src/Model/CoreEntityTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@ protected function attachDynamicFields(array $aData,$oObject) {

return $aData;
}

public function updateAttribute($sAttribute,$sVal,$sIDKey,$iEntityID) {
$this->oTableGateway->update([$sAttribute=>$sVal],[$sIDKey=>$iEntityID]);
}
}
11 changes: 11 additions & 0 deletions module/Application/view/partial/viewform.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@
<div class="col-md-3">
<div class="card">
<div class="card-body text-center">
<?php if($oItem->hasFeaturedImage()) { ?>
<div style="max-width:250px; margin:auto;">
<!-- We'll transform this input into a pond -->
<input type="file" class="filepond" id="filepondtest">
</div>
<?php } ?>
<h2><?=$oItem->getLabel()?></h2>
<hr/>
<?php
$sCreatedDate = $oItem->getTextField('created_date');
if($sCreatedDate != '0000-00-00 00:00:00' && !empty($sCreatedDate)) { ?>
<div style="text-align: left;">
<small><?=$this->translate('Created')?>: <?=date('d.m.Y H:i',strtotime($sCreatedDate))?></small><br/>
<small><?=$this->translate('Last Edited')?>: <?=date('d.m.Y H:i',strtotime($oItem->getTextField('modified_date')))?></small>
</div>
<?php } ?>
</div>
</div>
</div>
Expand Down

0 comments on commit 5e275fc

Please sign in to comment.