Maybe I'm missing something really fundamental...
What is the best way to have a menu of side tabs for a given index
view? Right now, I have this:
$options = array ('update' => '#main_content');
$options ['escape'] = false;
$options ['before'] = "";
foreach ($side_buttons as $side_button) {
$options ['before'] .= "document.getElementById
('mission_side_menu_".
$side_button ['name'].
"').className='side_menu_button';";
}
foreach ($side_buttons as $side_button) {
$options ['complete'] = "document.getElementById
('mission_side_menu_".
$side_button ['name'].
"').className='side_menu_button_sel';";
echo $this->Html->div ("side_menu_button",
$this->Js->link ($this->Html->tag
('span', $side_button ['title']),
array ('action'=>
'display/'.$side_button ['name']),
$options),
array ('id'=>'mission_side_menu_'.
$side_button ['name']));
}
You can see my action is display/ button name.
In my controller, display just does $this->render ($subtab). This
unfortunately keeps http://system/mission/subtab from working though.
Thanks for your help! I know I am close to understanding, just need a
little bit more...
Joey
On Oct 4, 8:48 pm, "Dr. Loboto" <[email protected]> wrote:
> Just check AJAX in view as $this->params['isAjax'] and output full
> view or only subtab element, that's all the difference. Same you can
> check in controller.
>
> On 5 ÏËÔ, 01:48, Joey Mukherjee <[email protected]> wrote:
>
>
>
> > It is different since the subtab is updated by Ajax. šAt least that's
> > what I think.
>
> > When I go directly tohttp://system/tabname/subtab, I get a message
> > saying (for instance) " Error: šThe action spacecraft is not defined
> > in controller MissionsController" š In this case "spacecraft" is my
> > subtab and Mission is my main tab. šThis makes sense in that I don't
> > have that routine defined. šHowever, I am at a loss for what to put in
> > that routine. šMy attempt at it would be:
>
> > š š function spacecraft ()
> > š š {
> > š š š š $this->render ('/elements/missions/spacecraft');
> > š š }
>
> > which displays my text, but not the rest of the tabs (i.e. the stuff I
> > have on the index.ctp view). šWhat I'd like is:
>
> > $this->render ('index');
> > $this->render ('/elements/missions/spacecraft'); // this will just
> > "manually" switch tabs for the user.
>
> > Hope this makes sense!
>
> > Thanks!
> > Joey
>
> > On Oct 4, 12:15špm, Miles J <[email protected]> wrote:
>
> > > And again, what your saying is exactly what a controller and action is
> > > for. How is that different than your setup?
>
> > > On Oct 4, 7:30šam, Joey Mukherjee <[email protected]> wrote:
>
> > > > In retrospect, I guess I didn't explain as well as I should have.
>
> > > > I have each subtab as an element now and every subtab is rendered via
> > > > ajax (i.e. š$js->link ($html->tag ('span', $side_button
> > > > ['title']),
> > > > array ('action'=> 'display/'.$side_button ['name']), $options). šThe
> > > > controller action "display" just has a $this->render ("/elements/
> > > > $tabname/$whatToDisplay");
>
> > > > So, when the user goes tohttp://system/tabname, the initial view sets
> > > > up the element specific to that tab that views/layouts/default.ctp did
> > > > not setup. šEach subtab element just has stuff specific to that subtab
> > > > (in my case, mainly just text).
>
> > > > However, I'd like people to go tohttp://system/tabname/subtaband
> > > > directly render the specific text to that subtab. šThat's what I can't
> > > > figure out??
>
> > > > Anyway, does this sound right to everyone? šI feel like I am the only
> > > > one having this problem on something which seems pretty common (tabs/
> > > >subtabs). šIs there ša better way of doing the above? šI'd welcome all
> > > > ideas!
>
> > > > Thanks for the response!
> > > > Joey
>
> > > > On Oct 1, 1:49špm, Miles J <[email protected]> wrote:
>
> > > > > Just use the default MVC architecture?
>
> > > > > tabname = controller
> > > > > subtab = action
>
> > > > > On Sep 30, 12:05špm, Joey Mukherjee <[email protected]> wrote:
>
> > > > > > I have some tabs along the top of my CakePHP site and some sub-tabs
> > > > > > along the left side of my page. šWhen I switch tabs, it goes to a
> > > > > > URL
> > > > > > such ashttp://system/tabname. šWhen I go to a sub-tab, I use
> > > > > > $this->render to update the content of the view to what the user
> > > > > > clicked
>
> > > > > > on. šHowever, I'd like a URL such ashttp://system/tabname/subtabto
> > > > > > go directly to the subtab.
>
> > > > > > How might I accomplish this? šBasically, I want to redirect to
> > > > > > tabname/
> > > > > > index and then render the subtab.
>
> > > > > > My tabname index view sets up the side menu. šThe subtab just
> > > > > > modifies
> > > > > > the inner content. šThe views/layouts/default.ctp has the top tabs
> > > > > > defined in them. šObviously, the side tabs change from tab to tab.
>
> > > > > > Hope that makes sense!
>
> > > > > > Thanks,
> > > > > > Joey
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" 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