Yeah, I've prefixed the element with an underscore.
Hmmm ... excellent (and obvious) idea with just using the relative
path from `elements` ...
Makes me think it'd be nice to write a `partial ()` function which
would take in the name and prepend the path + current controller; but
I can't seem to find out how to override the View similar to
app_controller for Controller, any thoughts??

I took a look at the Mini-controller but it's not quite fitting my
purposes and seems like extra work for something that should be
trivial (not to mention reading the page was hurting my eyes).

Thanks Joel!!

On Sep 22, 3:32 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
> I usually put these Controller-specific elements inside the same
> folder as the controller they are associated to.
> Example: create an 'emphasis.ctp' file, and place it in your views/
> photographers/ folder.  You can then render this element inside a
> photographer view template by calling <?php echo $this->element('../
> photographers/emphasis'); ?>. Remember that to pass in data to your
> element you need to pass in a data array as your second argument to
> $this::element (data given to the view is not automatically available
> to the element).
>
> You can, of course, place an underscore infront of the element name to
> adhere to a standard convention; since these elements are never
> directly associated to a controller action, then there shouldn't be a
> problem.
> This ensures that your application separates the global elements (e.g.
> header, footer) from the controller/view-specific elements.
>
> Alternatively, you could use a technique pioneered by AD7six known as
> mini-controllers:http://www.ad7six.com/MiBlog/Blogs/view/MiniControllers
> While I have not used it, there is a not-so-small legion of Bakers who
> swear it's the best thing since sliced bread.
>
> hth,
>
> -J.
>
> On Sep 22, 3:17 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > Here's the scenario:
>
> > I've got a list of Photographers; each Photographer has a list of
> > Emphases that they specialize in; each Emphasis has additional info
> > (like 'experience').
> > In the Edit view, I'm looping through the Emphases and creating the
> > form. However, I also have an "Add new" ajax functionality to
> > dynamically add a new Emphasis.
>
> > Now, obviously these 2 forms are identical, and would much rather
> > modularize these in to a single piece.
>
> > So far, from what I've found, my options are:
>
> > 1.) requestAction - which would retrieve the list of Emphases.
> > However: I already have that list when I retrieved the Photographer's
> > info, so that seems kind of redundant (plus processing overhead - yes,
> > I know it wouldn't be a lot)
>
> > 2.) renderElement. And here's my beef with 'elements': I will only
> > ever need this 'Emphasis' requirement from within 'Photographer', so
> > why should it go in 'elements' which are intended to be "small blocks
> > of presentation code that needs to be repeated from page to page...".
> > Strictly speaking, this is a small block that is repeated; however,
> > it's only specific to a Photographer. It just doesn't make much sense
> > to have it in a "global"-type folder.
>
> > I'm coming from a RoR background where such things would simply be
> > prefixed with an underscore ... so in this case, rather than have
> > `elements/emphasis.ctp` it would be in `photographers/
> > _emphasis.ctp` ... it's just more modular...
>
> > Thoughts??
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to