Login +

How To ? / Using component

Suppose that on your website, you had a recurring module like the last published articles on a sidebar.

Component LastArticles.controller.php:

$this->_generic->useModel("Article","main");
$article = new Main_Article();

$articles = $article->searchModels("article", array(), array(), array(), array(array("column"=>"article_date","order"=>"desc")));
for($i=0 ; $i<$count=count($articles) ; $i++)
{
    $this->_xmlToolBox->startTag("article");
    foreach($articles[$i] as $key => $value)
        $this->_xmlToolBox->addFullTag($key,$value,true);
    $this->_xmlToolBox->addFullTag("article_url", $this->_generic->getFullPath("Blog", "Article", array( array("key"=>"Id","value"=>$articles[$i]->article_id))),true);
    $this->_xmlToolBox->endTag("article");
}

Coupled with Generics XSL LastArticles.xsl:

<ul class="last_articles">
    <xsl:for-each select="//Components/Site/LastArticles/article">
        <li>
            <a href="{article_url}" title="{article_title}">
                <xsl:value-of select="article_title" />
            </a>
        </li>
    </xsl:for-each>
</ul>