Just a little more
In the bootstrap
// Head Script
$headScript = new Zend_View_Helper_HeadScript();
$headScript->appendFile(BASE_URL.'/public/scripts/calc.js',
'text/javascript');
$headScript->appendFile(BASE_URL.'/public/scripts/countAreaChars.js',
'text/javascript');
In your layout or view script:
<head>
<?php print($this->headMeta()."\n"); ?>
<?php print($this->headTitle()."\n"); ?>
<?php print($this->headLink()."\n"); ?>
<?php print($this->headScript()."\n"); ?>
</head>
See online documentation about Zend_View_Helpers :
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headscript
On Sat, Apr 4, 2009 at 3:44 AM, Matthew Weier O'Phinney <[email protected]>wrote:
> -- Innocentus <[email protected]> wrote
> (on Friday, 03 April 2009, 11:39 PM +0200):
> > I have a custom view helper which adds tooltips to a view.
> > JavaScript is needed for these tooltips so I need to add an external
> > JavaScript-file.
> > This I want to do when the view helper is called the first time -
> > because otherwise it is unnecessary.
> > Because I want to add more than only one tooltip I need to prevent
> > that this JavaScript-file is added multiple times.
> >
> > The JavaScript-file responsible for the tooltips should be added only
> > when the tooltip view helper is called and this only once.
> > Successive calls of the view helper shouldn't result in adding the
> > JavaScript-file multiple times.
> >
> > Now I don't know if there is already a mechanism for custom
> > view-helpers for doing so.
> > Maybe there is already something I could rely on.
>
> Take a look at the placeholders, and how the Dojo and jQuery view
> helpers work, as they give you exactly this type of functionality.
>
> What I would suggest is using the headScript() view helper within your
> custom view helper, as headScript() also has this built into its
> functionality.
>
> --
> Matthew Weier O'Phinney
> Software Architect | [email protected]
> Zend Framework | http://framework.zend.com/
>
--
Thomas VEQUAUD http://thomas.vequaud.free.fr/
Expert EPITECH en Ingénierie Informatique
Tél : +33(0)6.50.39.28.10 Fax: +33(0)9.58.46.10.07