Thanks for trying :)

Do I understand correctly, that you are invoking/calling/whatever an
element (Google Analytics) from the layout?
   John

On Apr 8, 2:27 pm, the_woodsman <elwood.ca...@gmail.com> wrote:
> John, let me give it another go!
>
> Googl analytics is still my best example.
>
> I want every single page to have the basic analytics snippet.
> I really don't want to have this in every single view- it'd be a big
> job to go through all the existing views and add the call to render
> the element (not very DRY), it makes my views more cluttered, and it
> introduces the risk that pages are deployed without the snippet,
> placing the burden on the developers to know about these snippets that
> have to be placed in every view they create!
>
> However, some pages need to completely override the default version in
> the layout.
> For example, analytics doesn't auto track 40x/50x HTTP responses, so I
> want to change the analytics code for specific views.
>
> So right now, my layout renders the analytics element, passing it a
> variable form viewVars if necessary.
>
> Then, my error page for 404s etc sets this variable to a custom value
> ("error-404") so we can track how often our users hit error pages.
>
> This technique is DRY (no unnecessary repetition of the same snippet),
> employs convention over config (the convention is analytics is handled
> in the layout, unless you're dealing with a special case), and there's
> no risk of analytics not being included on a page.
>
> None of the suggestions so far seem as elegant as this...?
>
[snip]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to