Skip to content

Commit

Permalink
Add documentation of the new RSS feed API
Browse files Browse the repository at this point in the history
Closes #413
  • Loading branch information
BurntimeX committed Apr 21, 2024
1 parent f8a1c16 commit 092633c
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/migration/wsc60/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ class MyForm extends AbstractForm {
}
}
```

## RSS Feeds

A [new API](../../php/api/rss_feeds.md) for the output of content as an RSS feed has been introduced.
89 changes: 89 additions & 0 deletions docs/php/api/rss_feeds.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
The RSS feed API makes it possible to output content in the RSS format in accordance with the [RSS 2.0 specifications](https://www.rssboard.org/rss-specification).
The [ArticleRssFeedPage](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/page/ArticleRssFeedPage.class.php) is available as a reference implementation.

## `RssFeed`

[RssFeed](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeed.class.php) represents an RSS feed.

After content has been added to the RSS feed, the feed can be output as XML using the `render` method.

Example:

```php
$feed = new RssFeed();
...
$output = $feed->render();
```

## `RssFeedCategory`

[RssFeedCategory](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedCategory.class.php) represents a category of a feed item. A feed item can have multiple categories.

An instance of `RssFeedCategory` is created implicitly when a category is assigned to a feed item.

Example:

```php
$item = new RssFeedItem();
$item->category('title', 'domain');
```

## `RssFeedChannel`

[RssFeedChannel](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedChannel.class.php) represents a channel within an RSS feed.

Example:

```php
$feed = new RssFeed();
$channel = new RssFeedChannel();
$channel
->title('title')
->description('description')
->link('https://www.example.net');
$feed->channel($channel);
```

## `RssFeedEnclosure`

[RssFeedEnclosure](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedEnclosure.class.php) represents an enclosure of a feed item. A feed item can only have one enclosure.

An instance of `RssFeedEnclosure` is created implicitly when an enclosure is assigned to a feed item.

Example:

```php
$item = new RssFeedItem();
$item->enclosure('url', /*size*/1024, 'mime/type');
```

## `RssFeedItem`

[RssFeedItem](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedItem.class.php) represents an item in an RSS feed.

Example:

```php
$feed = new RssFeed();
$channel = new RssFeedChannel();
$feed->channel($channel);

$item = new RssFeedItem();
$item
->title('title')
->link('url');
$channel->item($item);
```

## `RssFeedSource`

[RssFeedSource](https://github.com/WoltLab/WCF/blob/master/wcfsetup/install/files/lib/system/rssFeed/RssFeedSource.class.php) represents the scource of a feed item. A feed item can only have one scource.

An instance of `RssFeedSource` is created implicitly when an scource is assigned to a feed item.

Example:

```php
$item = new RssFeedItem();
$item->source('title', 'url');
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ nav:
- 'Package Installation Plugins': 'php/api/package_installation_plugins.md'
- 'User Activity Points': 'php/api/user_activity_points.md'
- 'User Notifications': 'php/api/user_notifications.md'
- 'RSS Feeds': 'php/api/rss_feeds.md'
- 'Sitemaps': 'php/api/sitemaps.md'
- 'Code Style': 'php/code-style.md'
- 'Apps': 'php/apps.md'
Expand Down

0 comments on commit 092633c

Please sign in to comment.