Skip to content

Commit a48fb4f

Browse files
committed
10133-Co-authors
1 parent fe1c4b2 commit a48fb4f

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

Model/Post.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,15 @@ public function getRelatedTags()
693693
return $this->_relatedTags;
694694
}
695695

696+
/**
697+
* Retrieve post tags
698+
* @return \Magefan\Blog\Model\ResourceModel\Tag\Collection
699+
*/
700+
public function getRelatedCoauthors()
701+
{
702+
return [];
703+
}
704+
696705
/**
697706
* Retrieve post tags count
698707
* @return int

Model/ResourceModel/Post.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,28 @@ public function incrementViewsCount(\Magento\Framework\Model\AbstractModel $obje
217217
);
218218
}
219219

220+
/**
221+
* Update post connections
222+
* @param \Magento\Framework\Model\AbstractModel $object
223+
* @param Array $newRelatedIds
224+
* @param Array $oldRelatedIds
225+
* @param String $tableName
226+
* @param String $field
227+
* @param Array $rowData
228+
* @return void
229+
*/
230+
public function updateLinks(
231+
\Magento\Framework\Model\AbstractModel $object,
232+
array $newRelatedIds,
233+
array $oldRelatedIds,
234+
$tableName,
235+
$field,
236+
$rowData = []
237+
)
238+
{
239+
return $this->_updateLinks($object, $newRelatedIds, $oldRelatedIds, $tableName, $field, $rowData);
240+
}
241+
220242
/**
221243
* Update post connections
222244
* @param \Magento\Framework\Model\AbstractModel $object
@@ -453,6 +475,17 @@ public function lookupRelatedProductIds($postId)
453475
return $this->_lookupIds($postId, 'magefan_blog_post_relatedproduct', 'related_id');
454476
}
455477

478+
/**
479+
* Get ids to which specified item is assigned
480+
* @param int $postId
481+
* @param string $tableName
482+
* @param string $field
483+
* @return array
484+
*/
485+
public function lookupIds($postId, $tableName, $field)
486+
{
487+
return $this->_lookupIds($postId, $tableName, $field);
488+
}
456489
/**
457490
* Get ids to which specified item is assigned
458491
* @param int $postId

view/frontend/templates/post/view-modern.phtml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@
4949
<?php } else { ?>
5050
<?= $block->escapeHtml($_author->getTitle()) ?>
5151
<?php } ?>
52+
53+
<?php
54+
$coAuthors = $_post->getRelatedCoauthors();
55+
$coAuthorsCount = count($coAuthors);
56+
?>
57+
<?php if (count($coAuthors)) { ?>
58+
<?= $block->escapeHtml(__('and')) ?>
59+
<?php $z = 0 ?>
60+
<?php foreach($coAuthors as $coAuthor) { ?>
61+
<?php $z++; ?>
62+
<?php if ($block->authorPageEnabled()) { ?>
63+
<a title="<?= $block->escapeHtml($coAuthor->getTitle()) ?>"
64+
href="<?= $block->escapeUrl($coAuthor->getAuthorUrl()) ?>"><?= $block->escapeHtml($coAuthor->getTitle()) ?></a><?php if ($z != $coAuthorsCount) echo ', ' ?>
65+
<?php } else { ?>
66+
<?= $block->escapeHtml($coAuthor->getTitle()) ?><?php if ($z != $coAuthorsCount) echo ', ' ?>
67+
<?php } ?>
68+
<?php } ?>
69+
<?php } ?>
5270
<span>-</span>
5371
</span>
5472
<?php } ?>

0 commit comments

Comments
 (0)