Monday, November 25, 2013

Re: Ordering of block content across view types

Gah, just realised that I don't add my layout scripts to the scripts block, so I imagine if I did, the order would be whacky.

On Tuesday, 26 November 2013 16:21:50 UTC+10, Reuben wrote:
Hi all

How does CakePHP know to put block content in the right order, for block content generated by different view types?

For example, you may add scripts in the layout, and you may add scripts in the view.  When the scripts block is rendered, layout scripts will appear before view scripts, even though the view is actually rendered before the layout.

I'm toying with a helper to assist with deferred loading, as described here : https://developers.google.com/speed/docs/best-practices/payload#DeferLoadingJS

So, I'm doing a DeferJsLoadHelper that extends the HtmlHelper.  It overrides script() to add the url to a list, and then I have a deferredBlock() that will create the script as seen in the link, though creating multiple script elements and appending them to the document.body.

However, scripts in my view are getting added to the top of the list, which is an issue, because the view scripts are dependent on the layout scripts getting loaded first (a jQuery dependency).

Somehow HtmlHelper->script() and css() manages to get it right, and I just can't see how it's doing it.

Regards
Reuben Helms

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: