English 中文(简体)
自愿的缔造者还建立了其他联系和行动,呼吁与《URL》建立联系。
原标题:zend paginator make other links and Action Calling concatinating with the URL

我是在我的第一个项目中使用zen的pa子。

<?php include "header.phtml"; ?>
<h1><?php echo  $this->escape($this->title);?></h1>
<h2><?php echo $this->escape($this->description);?></h2>
<a href="register">Register</a>
<table border="1" align="center">
<tr>
  <th>User Name</th>      
  <th>First Name</th>     
  <th>Last Name</th>      
  <th>Action</th>     
</tr>
 <?php 
 foreach($this->paginator as $record){?>  
<tr>
  <td><?php echo $record->user_name;?></td>
  <td><?php echo $record->first_name;?></td>      
  <td><?php echo $record->last_name;?></td>   
  <td>
    <a  href="edit/id/<?php echo $record->id;?>">Edit</a>
    |
    <a  href="del/id/<?php echo $record->id;?>">Delete</a>      
  </td>   
</tr> 
  <?php } ?>
 </table>

<?php echo $this->paginationControl($this->paginator,  Sliding ,  pagination.phtml ); ?>

 <?php include "footer.phtml"; ?>

正如我说过的那样,主食会带来罚款和工作罚款,但当我点击这些链接的时候。

 <a  id="edit_link" href="edit/id/<?php echo $record->id;?>">Edit</a>
                      or
 <a id="delete_link" href="del/id/<?php echo $record->id;?>">Delete</a>
                      or
 <a href="register">Register</a>

it is not calling the required action instead it make my url like this

(initial link) http://localhost/zend_login/web_root/index.php/task/list

after clicking any of the above link its like this

 http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/8
 http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/edit/id/23
 http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/edit/id/register        http://localhost/zend_login/web_root/index.php/task/list/page/edit/id/edit/id/del/id/12

<>strong>note, 并非首次出现,而是在点击任何想象力时,将其与被指责的行动联系起来,并展示一种看法。 采取行动

 public function listAction(){

      $registry = Zend_Registry::getInstance();  
      $DB = $registry[ DB ];
      $sql = "SELECT * FROM task ORDER BY task_name ASC";
      $result = $DB->fetchAll($sql);
      $page=$this->_getParam( page ,1);
      $paginator = Zend_Paginator::factory($result);
      $paginator->setItemCountPerPage(3);
      $paginator->setCurrentPageNumber($page);
      $this->view->assign( title , Task List );
      $this->view->assign( description , Below, are the  Task: );
      $this->view->paginator=$paginator;
     }
最佳回答

add this in your action

$request = $this->getRequest();
$this->view->assign( url , $request->getBaseURL());

替换您在这方面的联系

<a href="<?php echo $this->url."/task/register"?>">Add a Task</a>
<a href="<?php echo $this->url. /task/edit/id/ .$record->id;?>">Edit</a>
<a href="<?php echo $this->url. /task/del/id/ .$record->id;?>">Delete</a>
问题回答

Try:

// controller
$this->view->controllerName = $this->getRequest()->getControllerName();

// view script
<a href="<?php echo $this->controllerName .  /edit/id/  . $rec或d->id);?>">Edit</a> 
| 
<a href="<?php echo $this->controllerName .  /del/id/  . $rec或d->id);?>">Delete</a> 

<a href="<?php echo $this->baseUrl($controllerName .  /edit/id/  . $rec或d->id);?>">Edit</a> 
| 
<a href="<?php echo $this->baseUrl($controllerName .  /del/id/  . $rec或d->id);?>">Delete</a> 

第二例使用<条码>Url(><>>>>基准线(<>>>>)探测器,使用前线控制器的Ur。 如果你在你的前主计长中不设座标,那就试图猜测。 由于你没有利用boot装置功能建立基地 页: 1 (不需要):

$frontController = Zend_Controller_Front::getInstance(); 
$frontController->setBaseUrl( / );

第三种可能性:url( view helper:

<a href="<?php echo $this->url(array(
     controller  => $controllerName,
     action      =>  edit ,
     id          => $rec或d_->id
)); ?>">Edit</a> 
| 
<a href="<?php echo $this->url(array(
     controller  => $controllerName,
     action      =>  del ,
     id          => $rec或d_->id
));?>">Delete</a> 




相关问题
Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

Tagging with Zend Framework

I m trying to create the same solutions as below, but using a simple MySQL query (instead of the static version used below where the words/tags are implemented in the code). The name of the MySQL ...

dynamicaly adding textboxes to zend_form

I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows ...

热门标签