Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:18:33+00:00 2026-06-06T02:18:33+00:00

I have been working with Zend Framework for a few months now. I have

  • 0

I have been working with Zend Framework for a few months now. I have so far been succesfully using some view helpers, action helpers and partials. Now i have come across some javascript libraries i want to use in my project such as TinyMCE and others.

My question is, what is the best way to implement these in a Zend Project? Preferably i would like to be able to add or enable these javascript libraries on a view level. So for example when i go to my addSomething.phtml wich contains a zend_form, one of my text area’s becomes a TinyMCE editor field. However i do not want this on all my forms or even all my text area elements.

So what is the best way to implement and then approach these libraries under ZF 1.11.11?

Thanks in advance for any advice given 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:18:34+00:00Added an answer on June 6, 2026 at 2:18 am

    You can use a view helper to load javascript and css files on a per controller/view basis. This is something I have experimented with and I find it quite helpful, although I haven’t taken the step of putting it into a live project yet, I’m still assessing it.

    Here is the devzone article I got the idea from. All credit to Andy Baird for posting the technique.

    Basically you setup two view helpers, one for javascript:-

    class Zend_View_Helper_JavascriptHelper extends Zend_View_Helper_Abstract
    {   
        function javascriptHelper() {
            $request = Zend_Controller_Front::getInstance()->getRequest();
            $file_uri = 'media/js/' . $request->getControllerName() . '/' . $request->getActionName() . '.js';
    
            if (file_exists($file_uri)) {
                $this->view->headScript()->appendFile('/' . $file_uri);
            }
        }
    }
    

    and one for css:-

    class Zend_View_Helper_CssHelper extends Zend_View_Helper_Abstract 
    { 
        function cssHelper() { 
            $request = Zend_Controller_Front::getInstance()->getRequest(); 
            $file_uri = 'media/css/' . $request->getControllerName() . '/' . $request->getActionName() . '.css'; 
    
            if (file_exists($file_uri)) { 
                $this->view->headLink()->appendStylesheet('/' . $file_uri); 
            } 
    
            return $this->view->headLink(); 
    
        } 
    }
    

    Then you call them from your layout script:-

    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
        <title>My app title</title> 
        <? $this->headLink()->appendStylesheet('/media/css/global.css') ?> 
        <? $this->headLink()->appendStylesheet('/media/css/iefix.css','screen','lt IE 7') ?>     
        <?= $this->cssHelper() ?>    
        <? $this->headScript()->appendFile('/media/js/jquery-1.3.2.min.js') ?> 
        <? $this->headScript()->appendFile('/media/js/global.js') ?> 
    
        <? $this->javascriptHelper() ?> 
        <?= $this->headScript() ?> 
    </head>
    

    You then store your javascript and css files in folders that reflect the name of the action they are used with, for example:-

    media/js/index/index.js
    media/css/index/index.css

    to load css and javascript for you index action.

    In practice I have found it preferable to put javascript and css in the same folder, so I miss out the js & css parts of the paths above and adjust the $file_url variable in both helpers accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working with Zend for a few months now and am at
The Zend Framework based site I have been working on is now being migrated
So, I've been working with Zend Framework for more than 2 years now, and
I have been troubled in working with the FIND_IN_SET() sql query with zend framework
Have been working on a Tower Defense game for iOS for some time now.
I have been working in Zend Framework for a while and I am currently
I have been working on a new installation of a Zend Framework application for
I've been working in Zend Framework for over a year now, but I've never
For the past time I have been working on a Zend Framework based webshop
I have a Zend Framework application I've been working on my local machine, I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.