Skip to content

Quick and dirty RSS feed #4

@raphaelbastide

Description

@raphaelbastide

In a rss.php at the root of the project:

<?php

require_once __DIR__.'/config.php';
require_once __DIR__.'/lib/utils.php';
require_once __DIR__.'/lib/routes.php';
require_once __DIR__.'/lib/pagination.class.php';
require_once __DIR__.'/lib/views.php';

$request = (isset($_GET['r']))? $_GET['r'] : '/';
$posts = get_posts();
$sitebaseurl = "http://site.com";

$title = SITE_NAME;

// routes($request, $posts);
?>
<?php echo "<?xml version='1.0' encoding='UTF-8' ?>";  ?>
<rss version="2.0">

  <channel>
    <title><?php echo $title ?></title>
    <link><?php echo $sitebaseurl ?></link>
    <description>A cool decription</description>
    <?php $show_ad_index = 0 ?>
    <?php foreach ($posts as $slug => $post): ?>
        <?php $show_ad_index++ ?>
      <item>
        <title><?php echo $post->title ?></title>
        <link> <?php echo $sitebaseurl. SITE_URL . $slug ?></link>
      </item>
    <?php endforeach ?>
  </channel>
</rss>

…almost ready to be pushed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions