This may or may not help you:

http://snook.ca/archives/cakephp/elemental_conditional_content_with_cakephp/

2007/11/2, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> I get where we're going, but let's try on a real example. Please have
> a look at a type of site i usually work at in average (some are least
> complicated but few are many times more complicated): http://mapolitique.be/
>
> ok, the header menu and footer are easy.
> the commercials are doable with elements.
> but then i have: the big controller on the left-center, the poll,
> newsletter, tags, links, list of active members etc. These are totally
> different controllers. On this page they're all the same on all pages,
> but on other sites the right side will have to include only some of
> them + new others. I don't know how to put them together on the same
> page without requestAction.
> i would have to be mad to write in the main controller the actions for
> all of them. think at the redundancy.
>
> On Nov 3, 12:43 am, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
> > What I would do is use a component only in your main page controller -
> > the one that draws the other bits together.
> >
> > As far as the header and footer stuff goes, that would be best done
> > with Elements.
> >
> > For example:
> >
> > /app/controllers/components/logger.php
> > class LoggerComponent extend Object {
> >   function startUp(&$controller) {
> >     // do my logging etc
> >     $controller->set('headVars',$someStuff_for_header);
> >   }
> >
> > }
> >
> > /app/views/elements/header.ctp
> > blah blah <?php echo $headVar['stuff']; ?> blah blah
> >
> > /app/views/main/index.ctp
> > blah... $this->renderElement('header',$headVars);
> > blah blah blah blah
> > $this->renderElement('footer',$headVars);
> > blah
> >
> > class MainController extends AppController {
> >   var $components = array('Logger');
> >   function index() {
> >     // get a bunch of stuff.
> >   }
> >
> > }
> >
> > Of course another way would be to get the unrelated stuff into one
> > controller (shock horror!). Of course you could use var $use to
> > include the additional models, which lets you pull together other
> > content. That's not a great thing for performance, but then there's
> > always caching.
> >
> > Simon
> >
> > On Nov 2, 10:15 pm, "[EMAIL PROTECTED]"
> >
> > <[EMAIL PROTECTED]> wrote:
> > > it's true i don't respect the conventions all the time, because in
> > > some cases this can bring significant speed gains (necessary on
> > > heavily accessed sites).
> > > however, if you're kind enough to share, i would like to know 'the
> > > cake way' for this: i have to show on one page different kind of
> > > information ( totally unrelated ) - so i think i can't use only one
> > > controller (or maybe i'm mistaking), and on top of that, i want
> > > something that is called only once at the top of the page to perform
> > > several actions (log/set variables etc).
> >
> > > thanks for your patience,
> > > Cristian
> >
> > > On Nov 2, 11:56 pm, "[EMAIL PROTECTED]"
> >
> > > <[EMAIL PROTECTED]> wrote:
> > > > Sounds like you're not doing it the cake way.
> >
> > > > If you really really want to do that, your best bet is to use
> > > > loadModel. To be honest, what you're doing doesn't really fit the
> > > > cake, or MVC model particularly well, so if I were you I would look at
> > > > elements as an alternative to all the requestActions.
> >
> > > > If you stick to Cake's conventions based approach, your best bet is
> > > > still to do the work in app_controller, or a component.
> >
> > > > Simon
> >
> > > > On Nov 2, 9:43 pm, "[EMAIL PROTECTED]"
> >
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > If I write that in the startup function of the component it will be
> > > > > called for the every controller in a page (which is not good because I
> > > > > use 'requestAction' a lot so startup will be called more than once).
> > > > > What I was actually thinking is to create my own class and call the
> > > > > initialization somewhere in bootstrap, but i don't know how to use a
> > > > > model by itself in a custom class.
> >
> > > > > On Nov 2, 2:43 pm, "[EMAIL PROTECTED]"
> >
> > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > What you probably want to do is write a component and handle your
> > > > > > logging in the startup function.
> >
> > > > > > You probably also want to be using the component to inform the
> > > > > > controller as to layout / views to use for the skinning. Depending 
> > > > > > on
> > > > > > your controllers, there are all sorts of ways you could do this,
> > > > > > ranging from $controller->layout = 'skin' in component startup to a
> > > > > > beforeRender filter.
> >
> > > > > > To get access to the db tables in your component, you'll have to use
> > > > > > loadModel to grab instances for the logging and prefs etc.
> >
> > > > > > Pages controller is something totally different. It is a simple
> > > > > > controller to just display views from the /app/views/pages directory
> > > > > > without the hastle of creating actions. Essentially it is for static
> > > > > > content. However, it could be informed by your component to change 
> > > > > > the
> > > > > > layout (skin) around static content and to log user progress if you
> > > > > > add your component to AppController in /app/app_controller.php.
> >
> > > > > > Hope that helps.
> >
> > > > > > Simon
> >
> > > > > > On Nov 2, 12:30 pm, Cristian Vrabie <[EMAIL PROTECTED]> wrote:
> >
> > > > > > > hi everybody,
> > > > > > > i'm new to phpcake organization model and i'm having some problems
> > > > > > > integrating some classes. maybe you can give me a hand.
> >
> > > > > > > i need a "visitor" class that will be responsible with tracking a 
> > > > > > > site
> > > > > > > 'visitor' (not a user), keep a track and use his settings (like 
> > > > > > > language
> > > > > > > and skin preferences) via cookies and similar stuff. the thing 
> > > > > > > with this
> > > > > > > is: i don't know if this should be a controller or a component. i 
> > > > > > > would
> > > > > > > say it's a controller because it hase it's own models (like log 
> > > > > > > tables,
> > > > > > > preferences table, etc), but then, it has no view and must be 
> > > > > > > called
> > > > > > > (initialized) on every page before everything else, and be 
> > > > > > > accesible
> > > > > > > from any other controller.
> >
> > > > > > > what should i do? i saw a page_controller somewhere and i think i 
> > > > > > > can
> > > > > > > use that but i'm not sure how?
> >
> > > > > > > what do you sugest. i'm sure this is a preaty common practice. 
> > > > > > > what do
> > > > > > > you use?
> >
> > > > > > > thanks,
> > > > > > > Cristian
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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