Skip to main content
Version: Fegg 5.x

Feed::add

Add a post

Description​

public Feed Feed::add( array $item )

Adds a post and returns the feed, so calls can be chained. Posts are written in the order they are added: add the newest first.

Throws \InvalidArgumentException when the item has neither a title nor a link, or a date cannot be read.

Arguments​

NameData typeDefaultRemarks
$itemarraySee below

Item​

KeyRemarks
titleTitle of the post
linkPath or URL of the post
date'Y-m-d H:i:s' from the database, a Unix time or a date object. Empty or '0000-00-00 00:00:00': no date
contentHTML of the post, written in <content:encoded>. src="/…" and href="/…" get the domain
descriptionPlain text. When missing, made from content (see What is written)
categoryA name, or a list of names
guidID of the post. Default: the link (isPermaLink="true")

Example​

Controller
use Fegg\Tool\Feed;

$feed->add(array(
'title' => $row['title'],
'link' => '/news/post_' . $row['news_id'] . '.html',
'date' => $row['post_date'],
'category' => array('お知らせ', 'イベント'),
'content' => $row['content'],
));