动作“默认/显示”不存在Symfony 1.4 Jobeet第7天

时间:2012-02-16 15:30:44

标签: php doctrine symfony-1.4 yaml

我一直在关注Jobeet教程。我在第7天。我已相应地复制了文件,但收到了404错误:

Action "default/show" does not exist

模块/类别/动作/的actions.class.php

class categoryActions extends sfActions
{
    public function executeShow(sfWebRequest $request)
    {
        $this->category = $this->getRoute()->getObject();
        $this->pager = new sfDoctrinePager('JobeetJob', sfConfig::get('app_max_jobs_on_category'));
        $this->pager->setQuery($this->category->getActiveJobsQuery());
        $this->pager->setPage($request->getParameter('page', 1));
        $this->pager->init();
    }
}

模块/类别/模板/ showSuccess.php

<?php use_stylesheet('jobs.css') ?>

<?php slot('title', sprintf('Jobs in the %s category', $category->getName())) ?>

<div class="category">
    <div class="feed"><a href="">Feed</a></div>
    <h1><?php echo $category ?></h1>
</div>

<?php include_partial('job/list', array('jobs' => $category->getActiveJobs())) ?>


<?php if ($pager->haveToPaginate()): ?>
    <div class="pagination">
    <a href="<?php echo url_for('category', $category) ?>?page=1">
        <img src="http://www.symfony-project.org/images/first.png" alt="First page" title="First page" />
    </a>

    <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $pager->getPreviousPage() ?>">
        <img src="http://www.symfony-project.org/images/previous.png" alt="Previous page" title="Previous page" />
    </a>

    <?php foreach ($pager->getLinks() as $page): ?>
        <?php if ($page == $pager->getPage()): ?>
            <?php echo $page ?>
            <?php else: ?>
            <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $page ?>"><?php echo $page ?></a>
        <?php endif; ?>
    <?php endforeach; ?>
    <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $pager->getNextPage() ?>">
        <img src="http://www.symfony-project.org/images/next.png" alt="Next page" title="Next page" />
    </a>
    <a href="<?php echo url_for('category', $category) ?>?page=<?php echo $pager->getLastPage() ?>">
        <img src="http://www.symfony-project.org/images/last.png" alt="Last page" title="Last page" />
    </a>
    </div>
<?php endif; ?>

<div class="pagination_desc">
    <strong>
    <?php echo count($pager) ?>
    </strong> 
    jobs in this category <?php if ($pager->haveToPaginate()): ?> - page <strong><?php echo $pager->getPage() ?>/<?php echo $pager->getLastPage() ?>
    </strong>
<?php endif; ?>
</div>

前端/配置/ routing.yml中

category:
 url: /category/:slug
 class: sfDoctrineRoute
 param: { model: category, action: show }
 options: { model: JobeetCategory, type: object }

job:
 class: sfDoctrineRouteCollection
 options: { model: JobeetJob }

job_show_user:
 url: /job/:company_slug/:location_slug/:id/:position_slug
 class: sfDoctrineRoute
 options:
  model: JobeetJob
  type: object
  method_for_query: retrieveActiveJob
 param: { module: job, action: show }
 requirements:
  id: \d+
  sf_method: [get]

# default rules

homepage:
 url:   /
 param: { module: job, action: index }

#default_index:
# url:   /:module
# param: { action: index }
#
#default:
# url:   /:module/:action/*

我按照手册说明删除了indexSuccess.php。不确定这是不是问题。任何帮助都会很棒!

1 个答案:

答案 0 :(得分:1)

想出来。这是一个简单的拼写错误。我不得不使用Beyond Compare来看它。

category:
 url: /category/:slug
 class: sfDoctrineRoute
 param: { model: category, action: show }
 options: { model: JobeetCategory, type: object }

应该是:

category:
 url: /category/:slug
 class: sfDoctrineRoute
 param: { module: category, action: show }
 options: { model: JobeetCategory, type: object }

模型和模块之间的巨大差异。