一般来说,如果你的关系是设置正确(我不知道,如果你需要做的Symfony什么让这个)你只是做类似与类别Jobeet的教程...
在作业的actions.class.php文件中,你有executeIndex,并且它里面有$ this-> categories = JobeetCategoryPeer :: getWithJobs();
这是做什么找到模型JobeetCategoryPeer并调用该模型中的getWithJobs()函数,然后它将该数据返回到作业控制器发送到视图作为$类别。
所以,你会想要做类似的事情,所以在JobeetArticlesPeer创建一个函数返回所需的数据...
static public function getArticles()
{
$criteria = new Criteria();
//whatever criteria you want in here
return self::doSelect($criteria);
}
而在你JobeetJob actions.class.php文件里的类似
public function executeIndex(sfWebRequest $request)
{
$this->articles = JobeetArticlesPeer::getArticles();
}
并且最后在indexSuccess.php的为JobeetJob
<?php foreach ($articles as $article): ?>
<div class="article">
<div class="article_title">
<h1>
<?php echo link_to($article, 'article', $article) ?>
</h1>
<?php echo $article->getAuthor() //field name for author ?>
</div>
<div class="article_content">
<?php echo $article->getContent() //field name for article content ?>
</div>
</div>
<?php endforeach; ?>
其中t帽子应该给你一个关于如何从其他模型访问数据的一般想法