On Mar 7, 1:16 am, Ant Cunningham <prodigital...@vectrbas-d.com>
wrote:
> layout.php is just a wrapper for the the template and contains the
> <head> section of the html, so all things that are added to the head are
> actually added to layout.php by the include_metas() call. so if in
> apps/applicationname/config/view.yml you do:
>
> all:
>    javascript:
>      - file1
>      - file2
>
> Then those javascripts will be added to all the views in the
> application. Likewise if you do that in
> apps/applicationname/modulename/config/view.yml, then it will happen for
> all the action views (templates) in that particular module.
>
> The unless you define an absolute path then the file will be assumed to
> live web/javascript so th definitions above would have
> /javascript/file1.js and /javascript/file2.js as their src attribute.
> But not we are talking about the absolute path on the webserver not in
> the filesystem.
>
> if you need to add something programticaly on the fly like a stylesheet
> or javascript there are helpers for that in addition to manually
> manipulating the sfWebResponse object directly. No matter how you go
> about it though the result is the same - ie. the resource added to the
> head section of the document.


Well, I've tried everything and I've been unable to make this work.
The documentation seems to want me to set a variable in an action, and
that is what I'm trying to avoid. Ideally I could set a path in
view.yml and then echo it to the screen in layout.php. But I haven't
figured out any way to do this, without setting a variable in the
action.

What I had in layout.php was this:

        <script type="text/javascript" src="/bocahoops/web/js/jquery/
jquery-1.3.1.js"></script>

I didn't want to hard code the path, so I moved it to view.yml:

all:
  javascripts:
    - /bocahoops/web/js/jquery/jquery-1.3.1.js


Then I put this in layout.php:

        <?php use_javascript('jquery-1.3.1.js') ?>


I get nothing. I have to assume that the code expects me to set a
variable in the action. But I've almost 100 actions in this project so
far. I'm not going to set this variable in 100 different actions, that
would actually be a worse outcome than simply hard coding the path.

For now, I've gone back to hard coding the tag in layout.php:

        <script type="text/javascript" src="/bocahoops/web/js/jquery/
jquery-1.3.1.js"></script>

I am curious how to get access to the variables in view.yml. Are they
ever stored in sfView, even if they are not set in an action?

By the way, I'm using symfony 1.1.7
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to 
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to