1

i attach some stylesheets in zend controller but blank page shown,how i include stylesheets and javascript files in zend controller?here is my code:

public function showAction()
    {       
            //css

            $this->viewHelperManager->get('headLink')->appendStylesheet('/css/style.css');
            $this->viewHelperManager->get('headLink')->appendStylesheet('/css/bootstrap-theme.min.css');
            $this->viewHelperManager->get('headLink')->appendStylesheet('/css/tweaks.css');
            $this->viewHelperManager->get('headLink')->appendStylesheet('/css/fullcalendar.css');
            $this->viewHelperManager->get('headLink')->appendStylesheet('/css/fullcalendar.print.css');
            $this->viewHelperManager->get('headLink')->appendStylesheet('/css/jquery-ui.min.css');
            $this->viewHelperManager->get('headLink')->appendStylesheet('/css/jquery.simple-dtpicker.css');
            //js
            $this->viewHelperManager->get('headScript')->appendFile('/admin_static/js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js');
            $id = (int) $this->params()->fromRoute('id', 0);
            if (!$id) {
                return $this->redirect()->toRoute('calendar', array(
                    'action' => 'create'
                ));
            }
            $calendar = $id;
            $dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');
            $eventshow = $dm->createQueryBuilder('Calendar\Document\Calendar')
            ->hydrate(false)
            ->field("id")->equals($id)
            ->getQuery()->execute();
            $array = array();
            if($eventshow && !is_null($eventshow) && is_object($eventshow)){                    
                foreach($eventshow as $key=>$value) {   
                $array[] = array(
                        'calendar_id' => $value['_id'],
                        'user_id' => $value['user_id'],
                        'title' => $value['title'],
                        'description' => $value['description'], 
                    );
                }
            }
            return array('calendar' => $calendar , 'calendardata' => $array);
    }

1 Answer 1

1

The 'blank page' just means an error is being generated but you have display_errors turned off. Check your web server error log to see what the actual problem is (this will help you debug future issues as well).

From looking at your code, I'd guess the problem is with the calls to $this->viewHelperManager, as there is no such thing (unless you've set that elsewhere in your controller).

You probably want:

$this->getServiceLocator()->get('viewhelpermanager')->get('headLink')->appendStylesheet('/css/style.css');

although if you need that many view helper calls it might be worth passing the headLink helper in as a dependency.

Sign up to request clarification or add additional context in comments.

3 Comments

$this->getServiceLocator()->get('viewhelpermanager')->get('headScript')->appendFile('/js/jquery.min.js'); according to your code this line not include jquery in zend controller
Do you have a corresponding echo $this->headLink() call in your layout to output the HTML?
For scripts add $this->headScript();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.