0

我正在尝试将页面重定向回general_faq_category路由,但是当它被重定向时,数据未正确加载。所以我手动刷新页面,然后正确加载数据(排序)。为什么页面不自动刷新?它应该加载排序的数据,但在执行以下函数时它没有加载,但是在手动刷新路由后会出现更改。

以下是我用于重定向的代码

数据排序功能:

function executeFaqCategoryOrder(sfWebRequest $request) {
        $faqid = $request->getParameter('faqid');
        $direction = $request->getParameter('direction');
        if ($faqid & $direction) {
            $c = new Criteria();
            $c->add(FaqCategoryPeer::ID, $faqid);
            $current_faq = FaqCategoryPeer::doSelectOne($c);
            $current_order = $current_faq->getOrder();

            switch ($direction) {
                case 'UP':
                    $c = new Criteria();
                    $c->add(FaqCategoryPeer::ORDER, $current_order - 1);
                    $previous_faq = FaqCategoryPeer::doSelectOne($c);
                    $current_faq->setOrder($previous_faq->getOrder());
                    $current_faq->save();
                    $previous_faq->setOrder($current_order);
                    $previous_faq->save();
                    $this->redirect($this->generateUrl('general_faq_category'));
                    break;
                    break;
                case 'DOWN':
                    $c = new Criteria();
                    $c->add(FaqCategoryPeer::ORDER, $current_order + 1);
                    $next_faq = FaqCategoryPeer::doSelectOne($c);
                    $current_faq->setOrder($next_faq->getOrder());
                    $current_faq->save();
                    $next_faq->setOrder($current_order);
                    $next_faq->save();
                    $this->redirect($this->generateUrl('general_faq_category'));
                    break;
                    break;
                default:
                    $this->redirect($this->generateUrl('general_faq_category'));
                    break;
            }
             $this->redirect($this->generateUrl('general_faq_category'));
        }
    }

来自actions.php的另一个函数

public function preExecute() {

        self::$formName = "FaqCategoryAdminForm";
        self::$modelPeer = "FaqCategoryPeer";
        self::$model = "FaqCategory";

        $this->redirectUrl = 'faq_category/index';
    }

查看代码:

<div class="pagead">
  <div class="pagein"align="center">
    <div align="center">
      <h3>FAQ Category (Total: <?php echo $total ?>)</h3>
      <span style="float: right;">
        <a href="<?php echo url_for('faq/index') ?>" title="Back to FAQs">Back</a> | 
        <a href="<?php echo url_for($sf_params->get('module') . '/new') ?>" title="Click to add new category">New&nbsp;&nbsp; FAQ Category</a>
      </span>
    </div>
    <br/>
    <div align="center"><?php $pager->render() ?></div>
    <table width="100%" id="category">
      <tr>
        <th width="30%">Name</th>
        <th width="15%">Created At</th>
        <th width="5%">Order</th>
        <th width="12%">Action</th>
      </tr>
      <?php foreach ($pager->getResults() as $row): ?>
        <tr id="category_<?php echo $row['id'] ?>" class="categories">
          <td align="center"><?php echo $row['name']; ?></td>
          <td align="center"><?php echo date(sfConfig::get('app_display_alternate_format_for_date'), strtotime($row['created_at'])); ?></td>
          <td>
            <a href="<?=url_for('@drgug_faq_order?faqid=' . $row['id'] . '&direction=UP')?>">&#9650;</a>
            <a href="<?=url_for('@drgug_faq_order?faqid=' . $row['id'] . '&direction=DOWN')?>">&#9660;</a>
          </td>
          <td align="center">
            <?php echo link_to(image_tag("/images/edit.png", array("title" => "Click to modify category")), $sf_params->get('module') . '/edit?id=' . $row['id']); ?>
            <?php echo link_to(image_tag("/images/cross.png", array("title" => "Click to delete category")), $sf_params->get('module') . '/delete?id=' . $row['id'], array('confirm' => 'All related records will be deleted, are you sure ?')); ?>
          </td>
        </tr>
      <?php endforeach; ?>
    </table>
  </div>
  <br/>
  <br/>
</div>
<div class="bot"></div>
4

0 回答 0