[EXTENSION]menu

Hey, thanks alot =)

Yeah, deleting the files inside the Assets directory did the job, now i can access my CSS file, but each time i update it i have to manually go to the Assets directory and delete the files to trigger an update. Is there a way to, for debugging/developing, triggering the update of the Assets directory? (think of it as a cache->invalidate, if it was a caching mecanism)

Thanks

I can think of two possible solutions:

  1. Modify the extension in a way so that it pusblishes its assets on a per file basis. For published files, yii automatically checks the time the file has been modified and will republish it if necessary. As it doesn’t work for you, I guess this component publishes on a per directory basis, where this check is omitted. This might be the more straight foreward aproach. However, let me share some additional thoughts…

  2. Don’t modify the component css at all. Define more specific css rules within your application theme css files.

For example (imaginary one), if the component formats the content for all <p> elements as blod, but you dont want it bold but normal weight and green colored… The components css file would include a rule:




p {

  font-weight: bold;

}



You leave them as they are, but you know you placed the component within a wrapper div that has the id "wrapper". So you can specify your own css rule (somewhere in application theme css):




div#wrapper p {

  font-weight: normal;

  color: #00FF00;

}



This rule would overwrite the existing one the component defines itself, because it is more specific.

The second aproach might be especially usefull if you seperated your applications theme css files into different units for maintenance reasons. Think of a scenario where you use a seperate colors.css that only defines rules related to foreground/ background colors and maybe background images that need to fit the current color scheme. If you want to modify the color scheme of your application one day (or create a second one and maybe give the user the choice to switch between them), it would be much easier to only have to edit this one file instead of the one big application theme file plus all the css files of all the components you have used in your application.

Great extension, I suggest it would be great to add "active" tabs like the standard Yii MainMenu.

Thanks for the great extension!

This is good if you need different CSS ‘class’ or ‘id’ for your menu items.

Modification SMenu.php to allow ‘htmlOptions’ array in menu items:

Find:




$htmlOptions["class"]=$class;



Replace:




if ($htmlOptions["class"])

  $class .= " ".$htmlOptions["class"];

$htmlOptions["class"]=$class;



Note: There are two places need to be changed under function _createMenu();

This is a nice extension, that works as advertised, quickly and mostly painless.

I created [size="5"]this CSS that makes the menu bar resemble the default Yii main menu[/size].

I’ve only tried it in Safari, Firefox, Chrome and Opera, all for Mac, so I’m not sure if it will work in Internet Explorer.

Just copy and paste in the CSS directory of your Yii app, name it "menu.css" and then add in your layout:




<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/menu.css" />



This will override the style you may have entered when creating the widget. That’s the way I like it but you might want to do something else. Just keep in mind that this CSS uses the bg.gif that comes with the default Yii main menu and needs a proper URL if you place this CSS somewhere else.




ul.menu {

  list-style:none;

  margin:0;

  padding:0;

  position: absolute;

}


ul.menu * {

  margin:0;

  padding:0

}


ul.menu a {

  display:block;

  color: white;

  text-decoration:none;

  background-color: transparent;

  

}


ul.menu li {

  position:relative;

  float:left;

  

}


ul.menu ul {

  position:absolute;

  top:26px;

  left:0;

  background:transparent;

  display:none;

  opacity:0;

  list-style:none

}


ul.menu ul li {

  position:relative;

  /* border:1px solid #aaa; */

  border-top:none;

  width:120px;

  margin:0

}


ul.menu ul li a {

  display:block;

  padding:3px 7px 5px;

  background-color: transparent;

}


ul.menu ul li a:hover {

  height: 13px;

  background: #EFF4FA;

  border-top: 2px solid #8AB4D0;

  color: #6399cd;

}


ul.menu ul ul {

  left:120px;

  top:-1px

}


ul.menu .menulink {

  /* border:1px solid #aaa;*/

  padding:5px 7px 7px;

  font-weight:bold;

  width:134px;

  background: url('bg.gif') #5B98C2;

}


ul.menu .disabled {

  /* border:1px solid #aaa;*/

  padding:5px 7px 7px;

  font-weight:bold;

  width:134px;

  background-color: transparent;

  color: #cccccc;

}


ul.menu .disabled:hover {

  background: transparent;

  color: #cccccc;

}


ul.menu .menulink:hover, ul.menu .menuhover {

  height: 13px;

  background: #EFF4FA;

  border-top: 2px solid #8AB4D0;

  color: #6399cd;

}


ul.menu .sub {

  height: 13px;

}


ul.menu .arrow{

  top:6px;

  padding-left:10px;

  position:relative;

  float:right

}


ul.menu .sub2 {

 

}


ul.menu .topline {

  border-top-style: none;

  border-top-width: 0;

  border-top-color: black;

  border-right-style: none;

  border-left-style: none;

  border-bottom-style: none;

  border-right-width: 0;

  border-left-width: 0;

  border-bottom-width: 0;

}



Does this menu works with Yii 1.1.0?

It looks broken on a new webapp I made just for testing…

I copied the example code from the extensions’ documentation =/

got a big problem!

cant open all sites.


array('url'=>array('route'=>'site/about'), 'label'=>'About'),

got this code. but cant open the site. got this problem also by other selfgenerated sites… ERROR 404

all these files are in the general site direction.

also tried it with the option link instead of route.

anyone got an idea???

I’m tottaly new with Yii.

But got more experience in php

Now i understnad it.

These Sites are static sites. they dont need any action.

So how can i see static sites with this extension?

when you click on the menu item what does the address bar says?

is it

index.php?r=site/about ?

also try ‘route’=>’/site/about’

this error i get:

the adress bar says that:

tried both variations. nothing works yet.

could i realize another structure?

liek sites/static/xyz.php

cause i want to have it in different directions.

I have the same issue as sermon - did you ever find a solution?

Thanks for sharing the great extension. I have been using this menu in my application.

I have one question. Is it possible to display a confirmation message when the user chooses an option from the menu. For instance, if I have an Email option in the memu, can I display a message, "Are you sure that you want to send the Email?" in a dialog box, and if the user clicks No, the menu should not take any action to take the control to the route.

A workaround is to to have no link to this menu item and set an id for this in the htmlOptions




<?php

'url'=> array(         '',

        'htmlOptions'=>array('id'=>'sendEmail')      

 )

?>



Then use jquery




$("#sendEmail").click(function(){

if(confirm("realy send mail")){

...do things

}

});



Very nice and complete extension, thank you for sharing it.

I noticed some html errors on mine (version 1.0.4)… here is the diff file on how I fixed them.


diff -r 27ffe2fa50dd protected/extensions/menu/SMenu.php

--- a/protected/extensions/menu/SMenu.php	Sat Dec 11 01:16:01 2010 +0100

+++ b/protected/extensions/menu/SMenu.php	Sat Dec 11 01:34:44 2010 +0100

@@ -180,7 +180,7 @@

         $subImage = "";

         // If in top menu set class topline

         if(!$sub) {

-          $liClass= "class=topline";

+          $liClass= "class='topline'";

         }

         // If there's a menu item to display

         if($this->_isMenuItem($data)) {

@@ -220,6 +220,7 @@

             $this->_html .= "<ul>\n";

             $this->_html .= $this->_createMenu($data,true);

             $this->_html .= "</ul>\n";

+            $this->_html .= "</li>\n";

           }

         }

       }

(I used same quotes as the original code, even if that wouldn’t have been my personal choice)

Hi All,

Anybody know how to make this menu in a vertical fashion.

i mean, i need to display the menu in left hand side of the page.

pls help me…

Thanks

Sumesh

Hi.

I have need to use SMenu with ajax request.

I mean…

Is there any posbility to make links from SMenu as ajax request ?

I want to load subpages by ajax.

friend,

because when I move the mouse over the menu and shooting, the submenu is appearing like a watermark?

Adriano Silva

I love this menu, I’m struggling with one thing though…it doesn’t seem to recognize mailto: links as being similar to external links. So I can’t put a mailto link on the menu, any ideas on a work around?

Hi everybody.

First, this extension is the best menu’s extension i’ve found. Is flexible and easy to modify.

BUT I have an issue, I don’t know how I can apply a special style to a selected item like CMenu. For example, if a user click on the first item, this item will have a new style, for example, {text-decoration:underline;}.

How could I do that?

Thanks!

After I tried it, I got a message : Alias "application.extensions.menu.SMenu" is invalid. Make sure it points to an existing PHP file and the file is readable.

How to fix it ?

If I should install the extension before, how to do it ? Sorry, I’m newbie, so I couldn’t to install the extension in Yii. Thankyou