簡體   English   中英

動作“默認/顯示”不存在Symfony 1.4 Jobeet第7天

[英]Action “default/show” does not exist Symfony 1.4 Jobeet Day 7

我一直在關注Jobeet教程。 我在第7天。我已相應地復制了文件,但收到404錯誤:

Action "default/show" does not exist

modules / category / actions / 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();
    }
}

modules / category / templates / 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>

frontend / config / 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。 不知道這是否是問題。 任何幫助將是巨大的!

弄清楚了。 這是一個簡單的錯字。 我必須使用“超越比較”才能看到它。

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 }

型號與模塊之間的巨大差異

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM