Pop\Feed\Reader::setTemplate PHP Méthode

setTemplate() public méthode

Method to set item template
public setTemplate ( string $tmpl ) : Reader
$tmpl string
Résultat Reader
    public function setTemplate($tmpl)
    {
        if (file_exists($tmpl)) {
            $this->template = file_get_contents($tmpl);
        } else {
            $this->template = $tmpl;
        }
        return $this;
    }

Usage Example

Exemple #1
0
    public function testRssRender()
    {
        $tmpl = <<<NEWS
    <div class="news-div">
        <a href="[{link}]">[{title}]</a><br />
        <strong>[{published}]</strong> ([{time}])<br />
        <p>[{description}]</p>
    </div>

NEWS;
        $feed = new Feed\Reader(new Feed\Format\Rss('http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=h&output=rss', 4));
        $feed->setTemplate($tmpl);
        $this->assertContains('Google', $feed->title);
        $code = $feed->render(true);
        ob_start();
        $feed->render();
        $output = ob_get_clean();
        ob_start();
        echo $feed;
        $echoOutput = ob_get_clean();
        $this->assertContains('<div class="news-div">', $code);
        $this->assertContains('<div class="news-div">', $output);
        $this->assertContains('<div class="news-div">', $echoOutput);
    }