0

我在我的应用程序中使用了zend paginator,它的工作方式很好。但是当我点击任何链接时,我的意思是任何分页它查询正确的信息但css没有应用在那里。最初,当页面呈现所有css时,所有的css都被正确应用了我在刷新页面后点击任何分页css未应用。我不知道wts发生了什么?

这是做分页的动作

 public function controlpannelAction(){
      $data = Zend_Auth::getInstance()->getStorage()->read();  
      $user_id = $data->user_id;
      $registry = Zend_Registry::getInstance();  
      $DB = $registry['DB'];
      $sql = "SELECT * FROM `phone_service` WHERE user_id='".$user_id."'";
      $result = $DB->fetchAll($sql);
      $page=$this->_getParam('page',1);
      $paginator = Zend_Paginator::factory($result);
      $paginator->setItemCountPerPage(5);
      $paginator->setCurrentPageNumber($page);
      $this->view->paginator=$paginator;
   }

这是我的视图名称 controlpannel.phtml

<?php
include("header.phtml");
include("blue.phtml");
include("main1.phtml");
include("footer.phtml");
?>

所有的css都在header.phtml中。所有的css都在header.phtml中,所以这里是header.phtml

  <link rel="stylesheet" href="../../../web_root/assets/scripts/jqueryui/jqueryui.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../../web_root/assets/styles/style.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../../web_root/assets/styles/global.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../../web_root/assets/styles/config.css" type="text/css" media="screen" />
   .
   .
   .
   .
   and all other elements(body,divs)

这是我的应用程序的结构,我的意思是路径

    appname
    ->application
      -controllers
      -model
      -views
      -layouts
    ->library
      -zend
     ->web_root
       -index.php
       -assets
       -style
       -etc

这是我在 web_root 中的 index.php 也许这就是问题所在

 <?php
 error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
$rootDir = dirname(dirname(__FILE__));
set_include_path($rootDir . '/library' . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Controller/Front.php';
require_once 'Zend/Registry.php';
require_once 'Zend/Paginator.php';
include_once 'Zend/Db/Adapter/Pdo/Mysql.php';
require_once 'Zend/View.php';
require_once 'Zend/Controller/Action/Helper/ViewRenderer.php';
$params = array('host'         => 'localhost',
            'username'  => 'root',
            'password'    => '',
            'dbname'        => 'xyz'
           );

      $DB      = new Zend_Db_Adapter_Pdo_Mysql($params);
      $DB->setFetchMode(Zend_Db::FETCH_OBJ);
      Zend_Registry::set('DB',$DB);

 $view = new Zend_View();
 $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
 $viewRenderer->setView($view);
 Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
 Zend_Controller_Front::run('../application/controllers');
  ?>

我想这很清楚地理解了这个问题?任何帮助请

4

1 回答 1

5

您包含 css 的方式并不好。我认为您遇到了问题,因为 url 会发生动态变化,因此相对路径无法按您的预期工作。你应该改用这个:

<link rel="stylesheet" href="<?php echo $this->baseUrl('/assets/scripts/jqueryui/jqueryui.css'); ?> ...
于 2012-01-25T15:38:11.313 回答