Yes, you can create a separate layout for that page where you could
implement some sort of mechanism to change the size of the container.
That would probably be the best solution from a performance
standpoint, and it can be set in the view.yml.  But that still leaves
the question of how to update the dynamic containers' style.

Also, I believe slots are cached (don't quote me on that though), and
I would stay away from the attribute method.  Say you need to change
the name of the param for some reason, it would be a maintenance
nightmare

I was thinking, you could also create temporary stylesheets and save
them to create your own little css file cache, something that have the
width value in the name so you could reuse them.  Then you could use
the include_stylesheet helper to add the autogenerated css file.
That way you can isolate all of this within a single component which
will keep your code cleaner.  You could test to see if the css file
had already been created and use it, otherwise create a new stylesheet
with the directives in it, write it then include it.  Then if things
change down the road, you just update the component, say if you needed
to also manage height or something.

Casey



On Sep 18, 4:19 pm, Georg Gell <geor...@have2.com> wrote:
> Again thanks for the answer.
> It seems to me that I have three possibilities:
>
> 1.) I can use
>
> $this->getContext()->getRequest()->setAttribute('style', 
> '<style>.item{width='.$width.'px;}</style');
> and use
>
> <?php echo $sf_request->getAttribute('style') ?>
> in layout.php
>
> 2.) I can use a slot
>
> 3.) I can define another layout file in view.yml for the module (at least I 
> think).
>
> Which of these options is best performance wise, how do they affect caching?
>
> Georg
>
> Casey schrieb:
>
>
>
> > Maybe you could use a filter or the preExecute method of the actions
> > class?  Without knowing at which point the data becomes available
> > thats the best that I can suggest.  Perhaps you could create a slot in
> > the layout within the head portion of the template.  If it really
> > truly is only that one value, you could set a slot to be just the
> > width integer in the style definition.  Then, use the has_slot method
> > to implement a default value.  Once you do that you can call the
> > setSlot method in your action to populate the width value.  Its
> > probably not the most maintainable solution either, but I don't know
> > that there is one.  The only other thing I can think of is to use ajax
> > calls to update the object's contents and size.
>
> > HTH,
> > Casey
> > On Sep 18, 2:27 pm, Georg Gell <geor...@have2.com> wrote:
>
> >> Hi,
>
> >> thanks for the answer.
> >> at 1) AFAIK <style> should ony be in <head>,  and I cannot put anything
> >> in <head> in my template, this would have to be in layout.php, and there
> >> I think I cannot access $this->style from the action, or can I?
> >> at 2 a) b) I only want to change one value dynamically for each request,
> >> so this css would have to be it's own action. I would like to avoid the
> >> overhead to create the action and add another request from the browser
> >> that slows down the page load.
> >> at 2 c) same reason like 1, I can't put anything in <head> from the
> >> template.
>
> >> Georg
>
> >> Alexandru-Emil Lupu schrieb:
>
> >>> 1)  in your action $this->style = '<style></style>'; and then in your
> >>> templates echo $foo;
> >>> 2) alternative css for the pages you want modified.
> >>> a)  from module/config/view.yml add
>
> >>> action:
> >>>   stylesheets: ["/alternate_index"] # check the doc
> >>> b) in your template add
> >>> <?php use_stylesheets("/alternate_index") ?>
> >>> c) add it by hand in your template
>
> >>> I would recomend just 2a or 2b, as being most appropriate for a long
> >>> term maintainability.
>
> >>> Alecs
>
> >>> On Fri, Sep 18, 2009 at 11:16 PM, Georg Gell <geor...@have2.com
> >>> <mailto:geor...@have2.com>> wrote:
>
> >>>     Hi,
>
> >>>     how can I include some custom style information in a specific
> >>>     template?
> >>>     I would like to change the size of some divs fitting to the items
> >>>     in them.
> >>>     So i think i am looking for a way to insert something like
> >>>     <style>.item{width:17px}</style> into the template, where the 17px
> >>>     will
> >>>     be different for each request.
> >>>     I could create a helper for that, and use it in layout.php, but what
> >>>     information is available to this helper during the time it is used?
> >>>     Probably nothing from the action?
>
> >>>     Any ideas?
>
> >>>     Georg
>
> >>> --
> >>> As programmers create bigger & better idiot proof programs, so the
> >>> universe creates bigger & better idiots!
> >>> I am on web:  http://www.alecslupu.ro/
> >>> I am on twitter:http://twitter.com/alecslupu
> >>> I am on linkedIn:http://www.linkedin.com/in/alecslupu
> >>> Tel: (+4)0748.543.798
--~--~---------~--~----~------------~-------~--~----~
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