Re: Tabs in Layout... Help Please.

2009-01-16 Thread Martin Westin

@Andrew
The reason the "li.active" method is so widely used is that is works
for CMSes and other "dynamic" applications where the contents of the
menu changes. The technique you describe uses hard-coded menu items
which I very rarely find to be sufficient for the applications I work
on.




On Jan 15, 10:05 pm, "ache...@gmail.com"  wrote:
> Nurvzy,
>
> Yes! This is the first time I've written anything and then been able
> to link to it. I don't like the idea of using your server to process
> this, I think it's a task much better suited to CSS I wrote about it
> here if you want to take a lookhttp://www.lifeiscake.com/posts/view/css-menus
>
> Sincerely,
> ~Andrew Allen
>
> On Jan 13, 4:05 pm, nurvzy  wrote:
>
> > Hi All,
>
> >   I'm new to cakephp and working through my first cake app.  I'm
> > chugging along and am now stumped as to where to put a function I've
> > written to help decide if a navigation tab should have the
> > id="selected" assigned to the anchor tag.
>
> > Basically the gist is I have a  Navigation bar with various links:
> > (Home, Contact, ect..) and depending on the current controller or
> > action or whatever I pass in; I want the id of that  tag to be
> > "selected".
>
> > So I've written a little function:
>
> > function is_selected($controller_or_action, $link_text){
> >   if (strpos($controller_or_action,$link_text) !== false) return true;
> >   else return false;
>
> > }
>
> > And I'm calling it like so in the default.ctp layout:
>
> >  >  if(is_selected($this->params['controller'], "pages")) echo $html->link
> > ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> > array('id' => 'selected'));
> > else echo $html->link('Contact', array('controller' => 'pages',
> > 'action' => 'contactus'));
> >  ?>
>
> > But that's really tedious and quite ugly, plus I have that function
> > just written at the top of the layout which is a big no-no.  So I'm
> > looking for some help/advice.  How do you specify a tab type layout in
> > your cake app?
>
> > Thank you for your advice and/or help.
> > Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-15 Thread nurvzy

@Andrew: Thank you very much for the link to your great article; its
well written and much appreciated.

Thank you all for your quick responses, help and advice.  Very much
appreciated!

Nick
On Jan 15, 2:05 pm, "ache...@gmail.com"  wrote:
> Nurvzy,
>
> Yes! This is the first time I've written anything and then been able
> to link to it. I don't like the idea of using your server to process
> this, I think it's a task much better suited to CSS I wrote about it
> here if you want to take a lookhttp://www.lifeiscake.com/posts/view/css-menus
>
> Sincerely,
> ~Andrew Allen
>
> On Jan 13, 4:05 pm, nurvzy  wrote:
>
> > Hi All,
>
> >   I'm new to cakephp and working through my first cake app.  I'm
> > chugging along and am now stumped as to where to put a function I've
> > written to help decide if a navigation tab should have the
> > id="selected" assigned to the anchor tag.
>
> > Basically the gist is I have a  Navigation bar with various links:
> > (Home, Contact, ect..) and depending on the current controller or
> > action or whatever I pass in; I want the id of that  tag to be
> > "selected".
>
> > So I've written a little function:
>
> > function is_selected($controller_or_action, $link_text){
> >   if (strpos($controller_or_action,$link_text) !== false) return true;
> >   else return false;
>
> > }
>
> > And I'm calling it like so in the default.ctp layout:
>
> >  >  if(is_selected($this->params['controller'], "pages")) echo $html->link
> > ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> > array('id' => 'selected'));
> > else echo $html->link('Contact', array('controller' => 'pages',
> > 'action' => 'contactus'));
> >  ?>
>
> > But that's really tedious and quite ugly, plus I have that function
> > just written at the top of the layout which is a big no-no.  So I'm
> > looking for some help/advice.  How do you specify a tab type layout in
> > your cake app?
>
> > Thank you for your advice and/or help.
> > Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-15 Thread ache...@gmail.com

Nurvzy,

Yes! This is the first time I've written anything and then been able
to link to it. I don't like the idea of using your server to process
this, I think it's a task much better suited to CSS I wrote about it
here if you want to take a look http://www.lifeiscake.com/posts/view/css-menus

Sincerely,
~Andrew Allen

On Jan 13, 4:05 pm, nurvzy  wrote:
> Hi All,
>
>   I'm new to cakephp and working through my first cake app.  I'm
> chugging along and am now stumped as to where to put a function I've
> written to help decide if a navigation tab should have the
> id="selected" assigned to the anchor tag.
>
> Basically the gist is I have a  Navigation bar with various links:
> (Home, Contact, ect..) and depending on the current controller or
> action or whatever I pass in; I want the id of that  tag to be
> "selected".
>
> So I've written a little function:
>
> function is_selected($controller_or_action, $link_text){
>   if (strpos($controller_or_action,$link_text) !== false) return true;
>   else return false;
>
> }
>
> And I'm calling it like so in the default.ctp layout:
>
>   if(is_selected($this->params['controller'], "pages")) echo $html->link
> ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> array('id' => 'selected'));
> else echo $html->link('Contact', array('controller' => 'pages',
> 'action' => 'contactus'));
>  ?>
>
> But that's really tedious and quite ugly, plus I have that function
> just written at the top of the layout which is a big no-no.  So I'm
> looking for some help/advice.  How do you specify a tab type layout in
> your cake app?
>
> Thank you for your advice and/or help.
> Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread Kappa

Why not using "for_layout" variables?

Just set into your controller action a "selectedtab_for_layout"
variable and inside the
layout (yes i said layout, not view) you can access it.


On Jan 14, 5:42 pm, teknoid  wrote:
> If I understand this right, you are looking to set an "active" tab,
> based on the view you are currently in...
>
> It can be done easily from the view itself, i.e. in view_one.ctp:
> $this->set('tabOne', true); (which is now going to be available in
> your layout).
> Therefore, in the layout you could do:  'class="selected-tab"' : null; ?>
>
> On Jan 13, 6:05 pm, nurvzy  wrote:
>
> > Hi All,
>
> >   I'm new to cakephp and working through my first cake app.  I'm
> > chugging along and am now stumped as to where to put a function I've
> > written to help decide if a navigation tab should have the
> > id="selected" assigned to the anchor tag.
>
> > Basically the gist is I have a  Navigation bar with various links:
> > (Home, Contact, ect..) and depending on the current controller or
> > action or whatever I pass in; I want the id of that  tag to be
> > "selected".
>
> > So I've written a little function:
>
> > function is_selected($controller_or_action, $link_text){
> >   if (strpos($controller_or_action,$link_text) !== false) return true;
> >   else return false;
>
> > }
>
> > And I'm calling it like so in the default.ctp layout:
>
> >  >  if(is_selected($this->params['controller'], "pages")) echo $html->link
> > ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> > array('id' => 'selected'));
> > else echo $html->link('Contact', array('controller' => 'pages',
> > 'action' => 'contactus'));
> >  ?>
>
> > But that's really tedious and quite ugly, plus I have that function
> > just written at the top of the layout which is a big no-no.  So I'm
> > looking for some help/advice.  How do you specify a tab type layout in
> > your cake app?
>
> > Thank you for your advice and/or help.
> > Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread teknoid

If I understand this right, you are looking to set an "active" tab,
based on the view you are currently in...

It can be done easily from the view itself, i.e. in view_one.ctp:
$this->set('tabOne', true); (which is now going to be available in
your layout).
Therefore, in the layout you could do: 

On Jan 13, 6:05 pm, nurvzy  wrote:
> Hi All,
>
>   I'm new to cakephp and working through my first cake app.  I'm
> chugging along and am now stumped as to where to put a function I've
> written to help decide if a navigation tab should have the
> id="selected" assigned to the anchor tag.
>
> Basically the gist is I have a  Navigation bar with various links:
> (Home, Contact, ect..) and depending on the current controller or
> action or whatever I pass in; I want the id of that  tag to be
> "selected".
>
> So I've written a little function:
>
> function is_selected($controller_or_action, $link_text){
>   if (strpos($controller_or_action,$link_text) !== false) return true;
>   else return false;
>
> }
>
> And I'm calling it like so in the default.ctp layout:
>
>   if(is_selected($this->params['controller'], "pages")) echo $html->link
> ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> array('id' => 'selected'));
> else echo $html->link('Contact', array('controller' => 'pages',
> 'action' => 'contactus'));
>  ?>
>
> But that's really tedious and quite ugly, plus I have that function
> just written at the top of the layout which is a big no-no.  So I'm
> looking for some help/advice.  How do you specify a tab type layout in
> your cake app?
>
> Thank you for your advice and/or help.
> Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread nurvzy

A That's mighty clever too Martin, thanks for sharing.  I have a
static menu but I like the idea of not having to pass anything to the
view and the layout figuring out where it is on its own.  My problem
is I'm using the same pages controller to display 3 of my 6 tabs with
static content, so the controller name is the same 3 out of 6 times so
I needed another way to decide between them all.

But thanks for sharing, I'll keep that in mind for my next projects.

On Jan 14, 3:36 am, Martin Westin  wrote:
> One technique I have used where I want it to be as automatic as
> possible (but possibly not compatible with any routing scenario) is
> this:
>
> My main menu consists of either plugins or controllers (some of each
> kind.) So I use this to figure out what the current plugin or top-
> level controller is:
> ---
> if ( empty($this->plugin) ) {
>     $module_name = $this->name;} else {
>
>     $module_name = $this->plugin;}
>
> ---
> Then I loop the currently available "modules" (controllers and plugins
> that should be visible).
> For each one I compare its name to the one extracted above and set the
> class to selected if it matches.
> ---
> foreach($modules as $one) {
>     $class = '';
>     if ( low($module_name) == low($one) ) {
>         $class = ' selected';
>     }
>     e('');
>     e( $html->link(___('main_menu_'.$one),'/'.$one) );
>     e('');}
>
> ---
> For the links I only need to go to the index action but there is
> nothing stopping you from using more detailed menu-data to make more
> complex versions of this technique.
>
> What I like it that I don't need any specific (hard coded) information
> in my layout. I can change out the available menuitems at any time. I
> do this to adapt the menu to the permissions each user has. They only
> need to see items that they actually can access. I construct the list
> of available "modules" in AppController::beforeFilter after Auth has
> done its thing.
>
> /Martin
>
> On Jan 14, 3:05 am, nurvzy  wrote:
>
> > Thank you Miles!
>
> > That technique is exactly what I was looking for!
>
> > Nick
>
> > On Jan 13, 5:04 pm, Miles J  wrote:
>
> > > This is how I do mine:
>
> > > // controller action
> > > function login() {
> > >         $this->set('activeTab', 'login');
>
> > > }
>
> > > // the view
> > > > > > href="#">Login
> > > > > > href="#">Signup
>
> > > Also, your function would go in the bootstrap.php file in your app/
> > > config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread Martin Westin


One technique I have used where I want it to be as automatic as
possible (but possibly not compatible with any routing scenario) is
this:

My main menu consists of either plugins or controllers (some of each
kind.) So I use this to figure out what the current plugin or top-
level controller is:
---
if ( empty($this->plugin) ) {
$module_name = $this->name;
} else {
$module_name = $this->plugin;
}
---
Then I loop the currently available "modules" (controllers and plugins
that should be visible).
For each one I compare its name to the one extracted above and set the
class to selected if it matches.
---
foreach($modules as $one) {
$class = '';
if ( low($module_name) == low($one) ) {
$class = ' selected';
}
e('');
e( $html->link(___('main_menu_'.$one),'/'.$one) );
e('');
}
---
For the links I only need to go to the index action but there is
nothing stopping you from using more detailed menu-data to make more
complex versions of this technique.

What I like it that I don't need any specific (hard coded) information
in my layout. I can change out the available menuitems at any time. I
do this to adapt the menu to the permissions each user has. They only
need to see items that they actually can access. I construct the list
of available "modules" in AppController::beforeFilter after Auth has
done its thing.

/Martin


On Jan 14, 3:05 am, nurvzy  wrote:
> Thank you Miles!
>
> That technique is exactly what I was looking for!
>
> Nick
>
> On Jan 13, 5:04 pm, Miles J  wrote:
>
> > This is how I do mine:
>
> > // controller action
> > function login() {
> >         $this->set('activeTab', 'login');
>
> > }
>
> > // the view
> > > > href="#">Login
> > > > href="#">Signup
>
> > Also, your function would go in the bootstrap.php file in your app/
> > config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-13 Thread nurvzy

Thank you Miles!

That technique is exactly what I was looking for!

Nick

On Jan 13, 5:04 pm, Miles J  wrote:
> This is how I do mine:
>
> // controller action
> function login() {
>         $this->set('activeTab', 'login');
>
> }
>
> // the view
> > href="#">Login
> > href="#">Signup
>
> Also, your function would go in the bootstrap.php file in your app/
> config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-13 Thread Miles J

This is how I do mine:

// controller action
function login() {
$this->set('activeTab', 'login');
}

// the view
>Login
>Signup

Also, your function would go in the bootstrap.php file in your app/
config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Tabs in Layout... Help Please.

2009-01-13 Thread nurvzy

Hi All,

  I'm new to cakephp and working through my first cake app.  I'm
chugging along and am now stumped as to where to put a function I've
written to help decide if a navigation tab should have the
id="selected" assigned to the anchor tag.

Basically the gist is I have a  Navigation bar with various links:
(Home, Contact, ect..) and depending on the current controller or
action or whatever I pass in; I want the id of that  tag to be
"selected".

So I've written a little function:

function is_selected($controller_or_action, $link_text){
  if (strpos($controller_or_action,$link_text) !== false) return true;
  else return false;
}

And I'm calling it like so in the default.ctp layout:

params['controller'], "pages")) echo $html->link
('Contact', array('controller' => 'pages', 'action' => 'contactus'),
array('id' => 'selected'));
else echo $html->link('Contact', array('controller' => 'pages',
'action' => 'contactus'));
 ?>

But that's really tedious and quite ugly, plus I have that function
just written at the top of the layout which is a big no-no.  So I'm
looking for some help/advice.  How do you specify a tab type layout in
your cake app?

Thank you for your advice and/or help.
Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---