Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create file Feed.php under Block directory, then simply put a few lines:
Code Block
php
php
<?php

namespace Apps\BooksTodoList\TodoListBlock;

class Feed extends \Phpfox_Component
{
    public function process()
    {
        return "block";
    }
}

Register that block in start.php:

Code Block
php
php
<?php
$module->addComponentNames('block',         [
            'todo.feed'     => Block\Feed::class,
        ]);
  1. Open Service/Callback.php then edit function getActivityFeed() where we assigned value for $aReturn, we also need to assign Todo item information to the block template file as well.
Code Block
php
php
 $aReturn = array_merge([
            'feed_title'        => $aItem['name'],
            'privacy'           => $aItem['privacy'],
            'feed_info'         => _p('post_new_to_do'),
            'feed_link'         => Phpfox::permalink('to-do-list.view',
                $aItem['task_id'], $aItem['name']),
            'feed_content'      => $aItem['name'],
            'total_comment'     => $aItem['total_comment'],
            'feed_total_like'   => $aItem['total_like'],
            'feed_is_liked'     => $isLiked,
            'feed_icon'         => '',
            'time_stamp'        => $aRow['time_stamp'],
            'enable_like'       => true,
            'comment_type_id'   => 'todo',
            'like_type_id'      => 'todo',
            'custom_data_cache' => $aRow,
            'load_block'        => 'blocktodo.feed', //add this line
        ], $aRow);

 //Assign todo information to template file:
  \Phpfox_Template::instance()->assign(
             [
                 'aItem'     => $aItem,
             ]);

return $aReturn;
  1. Finally, we create template file feed.html.php under view/block directory to show needed information:
Code Block
actionscript3
actionscript3
<div class="feed-share-content" style="display: table">
    <a href="{permalink module='todo.view' id=$aItem.task_id title=$aItem.name}"><h3>{$aItem.name}</h3></a>
    <p>{$aItem.description|clean|shorten:'15100':'View More':true|split:30}</p>
</div>

...