コード例 #1
0
ファイル: functions.php プロジェクト: AmbreB/ExercicesSimplon
<?php

require 'vendor/autoload.php';
use Michelf\Markdown;
$html = getPostList();
function getPostList()
{
    $dossier = "posts/*.md";
    $list = glob($dossier);
    $pages = makeLinkList($list);
    $page = getPagePath($pages);
    return markdownToHTML($page);
}
function makeLinkList($list)
{
    $pages = [];
    foreach ($list as $key) {
        $fileName = substr($key, 6, -3);
        array_push($pages, $fileName);
        $title = fopen($key, "r");
        $firstline = Markdown::defaultTransform(fgets($title));
        echo $link = "<a href='?page=" . $fileName . "'>" . $firstline . "</a>";
    }
    return $pages;
}
function getPagePath($pages)
{
    if (in_array($_GET["page"], $pages)) {
        $page = "posts/" . $_GET["page"] . ".md";
    }
    return $page;
コード例 #2
0
ファイル: page-news.php プロジェクト: vexdev/verita-animali
<?php

/*
Template Name: pagina news
*/
get_header();
?>
<div id="center">
  <?php 
get_sidebar();
?>
<div id="contenuto">

<?php 
echo getPostList('news', 5);
?>
 
</div>
<div class="clearall"></div>
</div>
<div id="partners">
<!-- Begin zooplus Partner Program Code -->
<a href="http://www.zooplus.it/shop/partner/zap143909"><img src="http://www.zooplus.it/affiliate/material/zap143909" alt="TUTTI GLI ANIMALI" width="468" height="60" border="0"/></a>
<!-- End zooplus Partner Program Code -->

<a href="http://laverabestia.org" target="_blank"><img src="http://laverabestia.org/images/banner/banneroriz.png" alt="Laverabestia.org - Animal Video Community" width="468" height="60" border="0" /></a></div>
<div class="clearall"></div>