Page 5 of 9

Posted: Sat 19. Feb 2005, 19:32
by Paal
Hi,

With version 1.2, based on http://www.phpwcms.de/forum/viewtopic.php?t=2609 topic I would like to create the following ccs menu (but I can not do it :( )

http://www.carp.hu/menu2/

- How can I do that all submenu open on mouseover (at the moment only the first submenu opens and the others with the first one)
- Different colours for the background, for the fonts and for the borders in case of mainmenu and in case of submenus.
- A small signal arrow should to be taken to the submenu where further submenus are.
- In main <ul>, the text of the link should start 19px from left, and 4px in case of submenus (top/bottom borders are 126px)
- The left border of the opening subblocks should be 1px and white.

Something like this:

In main <ul>
Normal:
- width: 126px
- height: 21px
- bg color: #DADADA
- border color: #FFFFFF
- font color: #000000
- link text 19px from the left

Selected (hover):
- font color: #FFFFFF + subArrow img 4px from left
- bg color: #990000


In submenu
Normal:
- width: 126px
- height: 21px
- bg color: #F21C0A
- border color: #FF483B
- font color: #FFFFFF
- link text 4px from the left

Selected (hover):
- font color: #FFFFFF + Arrow img 4px from left
- bg color: #990000
- subArrow img from 4px right

Full site:
Image

Zoom for menu:
Image

Normal submenu item:
Image

Selected submenu item (with sub-arrow but arrow is needed when it has submenus)

Image

Can it be possible?

Thx, Paul

Posted: Sat 19. Feb 2005, 20:28
by brans
--...--/index.php/topic,68.0.html

=> see my hint on the implementation of udm, with udm all this will be possible!

Posted: Mon 21. Feb 2005, 01:29
by Paal
brans wrote:--...--/index.php/topic,68.0.html

=> see my hint on the implementation of udm, with udm all this will be possible!
Hello Brans,

I try this menu, but the result little bad :(
Please help me for css coding!

I try create full-vertical style css menu like this
Image

but not work :(

Your menu, firs drop-down and next level open horizontal.

Thx, Paul

Posted: Mon 21. Feb 2005, 13:58
by Paal
Paal wrote:
brans wrote:--...--/index.php/topic,68.0.html

=> see my hint on the implementation of udm, with udm all this will be possible!
Hello Brans,

I tried this menu, but the result was a little bad :(
Please help me for css coding!

I tried to create full-vertical style css menu like this
Image

but it does not work :(

Your menu, at first drop-down and then the next level opens horizontal.

Thx, Paul
OK! I found this and

customize for me :D :
Image



What should I modify so that the menus with <a href="#"> and have submenu, can get a class="submenu" parameter, so:
<li><a href="#"> to <li><a href="#" class="submenu"> (e.g. an arrow shows that it has an open submenu)?


Js script to this version:

Code: Select all

<script type="text/javascript">
startList = function() {
	// code for IE
	if(!document.body.currentStyle) return;
	var subs = document.getElementsByName('submenu');
	for(var i=0; i<subs.length; i++) {
		var li = subs[i].parentNode;
		if(li && li.lastChild.style) {
			li.onmouseover = function() {
				this.lastChild.style.visibility = 'visible';
			}
			li.onmouseout = function() {
				this.lastChild.style.visibility = 'hidden';
			}
		}
	}
}
window.onload=startList;
</script>
The {DROPDOWN:integer} result:

Code: Select all

        <ul id=nav>
          <li><a href="#">Menu 1</a>
            <ul id=nav>
              <li><a href="#">Menu 1,1</a></li>
              <li><a href="#">Menu 1,2</a>
                <ul id=nav>
                  <li><a href="#">Menu 1,2,1</a></li>
                  <li><a href="#">Menu 1,2,2</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li><a href="#">Menu 2</a></li>
          <li><a href="#">Menu 3</a></li>
          <li><a href="#">Menu 4</a></li>
        </ul>

What I need:

Code: Select all

        <ul id=nav>
          <li><a href="#" class="submenu">Menu 1</a>
            <ul id=nav>
              <li><a href="#">Menu 1,1</a></li>
              <li><a href="#" class="submenu">Menu 1,2</a>
                <ul id=nav>
                  <li><a href="#">Menu 1,2,1</a></li>
                  <li><a href="#">Menu 1,2,2</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li><a href="#">Menu 2</a></li>
          <li><a href="#">Menu 3</a></li>
          <li><a href="#">Menu 4</a></li>
        </ul>
Tnx, Pau

POssible VERY clean CSS {DROPDOWN} Solution..firstneed input

Posted: Wed 2. Mar 2005, 17:35
by toszter
Hi everyone, 1st post.

I came across a CSS horizontal menu solution that I've developed statically with no javascript courtesy of peterned an e.meyer. It is elegant and clean CSS that's designed to work in IE/Win and Moz.

However, I have one small problem...

I am having a tough time understanding the usage of the 'class' array in build_dhtmlmenu() in the front.func.inc.php file in v1.2 of phpwcms. The use of 'count' and 'every' are my main interests..

Specifically, I need my menu to be written like this by build_dhtmlmenu()....(mind the level classes and the fact that they are numbered)

Code: Select all

<ul class="level1">
 <li><a href="url">dsfasd</a></li>
 <li><a href="url">sdfsa</a>

  <ul class="level2">
   <li><a href="url">sdfsd</a></li>
  </ul>

 </li>
 <li><a href="url">lkjdf</a></li>
 <li><a href="url">lkjdf</a>

  <ul class="level2">
   <li><a href="url">lkflk</a></li>
   <li><a href="url">kldf</a>

    <ul class="level3">
     <li><a href="url">dslkfj</a></li>
    </ul>

   </li>
   <li><a href="url">ksdfk</a></li>
  </ul>

 </li>
 <li><a href="url">dfkljf</a></li>
</ul>
I think the solution lies in the line defining count but how does one set count to be explicitly true? and then get it to append to the class called in the function declaration:

Code: Select all

function build_dhtmlmenu($start=0, $class='', $activeclass='', $counter=0) {
	// builds a <ul><li> list based on structure
	// layout settings for $class = array(
        // 'count'	=> 0 (if the depth should be added to class/id name)
	// 'every'	=> 0 (if set 1 every sub-<ul> will get the class/id name
	// 'ul_i'	=> 'mydhtmlid'
	// 'ul_c'	=> 'mydhtmlclass'
	// 'ul_ia'	=> 'mydhtmlactiveid'
	// 'ul_c'	=> 'mydhtmlactiveclass'
	// 'li_ca'	=> 'myactiveclass' (for setting different class for active <li>)

I am using a {DROPDOWN} replacement tag with the following script written into css_dropdown.php in the frontend_render directory:

Code: Select all

<?php $content['all'] = str_replace('{DROPDOWN}', build_dhtmlmenu(0, 'class="level"', 'class="active"'), $content['all']); ?>
So the question stands: how do I use count to append level numbers to all <ul class="levelX"> levels?

Thanks for any help. I'll post my complete CSS DROPDOWN solution when we get this cracked. It is really much cleaner than everything I've seen to date.

~toszter

Posted: Wed 2. Mar 2005, 17:46
by Paal
Paal wrote: What I need:

Code: Select all

        <ul id=nav>
          <li><a href="#" class="submenu">Menu 1</a>
            <ul id=nav>
              <li><a href="#">Menu 1,1</a></li>
              <li><a href="#" class="submenu">Menu 1,2</a>
                <ul id=nav>
                  <li><a href="#">Menu 1,2,1</a></li>
                  <li><a href="#">Menu 1,2,2</a></li>
                </ul>
              </li>
            </ul>
          </li>
          <li><a href="#">Menu 2</a></li>
          <li><a href="#">Menu 3</a></li>
          <li><a href="#">Menu 4</a></li>
        </ul>
Tnx, Pau
Result for this stucture:

Code: Select all

function build_dhtmlmenu($start=0, $class='', $activeclass='', $counter=0) {
   // builds a <ul><li> list based on structure
   // layout settings for $class = array(
   // 'count'   => 0 (if the depth should be added to class/id name)
   // 'every'   => 0 (if set 1 every sub-<ul> will get the class/id name
   // 'ul_i'   => 'mydhtmlid'
   // 'ul_c'   => 'mydhtmlclass'
   // 'ul_ia'   => 'mydhtmlactiveid'
   // 'ul_c'   => 'mydhtmlactiveclass'
   // 'li_ca'   => 'myactiveclass' (for setting different class for active <li>)
   
   $s = '';
   $g = '';

   $thfs = $GLOBALS["content"]["struct"];
   foreach($thfs as $key => $value)
   {
      $x = &$GLOBALS["content"]["struct"][$value["acat_struct"]];
      if($value["acat_struct"] != 0)
         $x["acat_has_children"] = 1;
      else
         $x["acat_has_children"] = 0;
   }

#   FOR DEBUG:
#   
#   echo("<pre>\n");
#   print_r($GLOBALS['content']['struct']);
#   echo("</pre>\n");

   foreach($GLOBALS['content']['struct'] as $key => $value) {
      if ($start == $GLOBALS['content']['struct'][$key]['acat_struct'] &&
         !$GLOBALS['content']['struct'][$key]['acat_hidden'] && $key)
      {
         $s .= '<li';
         if($key == $GLOBALS['aktion'][0] && $activeclass) $s .= ' '.$activeclass;
         $s .= '>';

         if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) {
            $s .= '<a href="index.php?';
            if($GLOBALS['content']['struct'][$key]['acat_alias']) {
               $s .= $GLOBALS['content']['struct'][$key]['acat_alias'];
            } else {
               $s .= 'id='.$key.',0,0,1,0,0';
            }
            $s .= '"';
            if($GLOBALS['content']['struct'][$key]['acat_has_children'])
               $s .= ' class="submenu" name="submenu"';
            $s .= '>';
         } else {
            $redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', '');
            $s .= '<a href="'.$redirect['link'].'"'.$redirect['target'].'>';
         }

         $s .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']);
         $s .= '</a>';

         $s .= build_dhtmlmenu($key, $class, $counter+1);

         $s .= "</li>\n";
      }
   }

   if($s) {
      $g  = "\n<ul";
      if(!$counter && $class) $g .= ' '.$class;
      $g .= ">\n".$s.'</ul>';
   }
   
   return $g;
}

Posted: Wed 2. Mar 2005, 18:31
by pico
Hi

can someone please tell me what I have to do to get it work

I'm complitly confused with all the changes in this and other Threads

I've tried it serval times but I think that I miss some Steps or so :?:

Posted: Wed 2. Mar 2005, 18:36
by toszter
--...--/index.php/topic,68.0.html

grub, this is the basic solution that stil uses javascript.. I've got something that uses no java and more streamlined CSS.

I'm just waiting on a little help from my friends.
I get by with a little help from my friends.

~toszter[/quote]

Posted: Wed 2. Mar 2005, 20:25
by toszter
However, I have one small problem...

I am having a tough time understanding the usage of the 'class' array in build_dhtmlmenu() in the front.func.inc.php file in v1.2 of phpwcms. The use of 'count' and 'every' are my main interests..
well, wouldn't you know it, I figured it out. And I didn't use 'count' or 'every'. I suspect the comments exist in anticipation of the v.2 release.

No worries, I tweaked the front.func.inc.php script a tiny amount to accomodate my needs. I'll have everything posted for everyone's enjoyment as soon as I get the whole setup complete.

It's not too good to be true, there is NO javascript in my solution. Big thanks to Ben at emergentmediagroup dot com for introducing me to phpwcms.

I hope this works...:roll:

toszter

Posted: Thu 3. Mar 2005, 10:41
by brans
hmm I can`t imagine a dropdown menu that is working in IE with no JS I`ve never such a thing before.

Solution 3: CSS DROPDOWN MENU - NO JavaScript

Posted: Thu 3. Mar 2005, 16:30
by toszter
Solution 3: CSS DROPDOWN MENU - NO JavaScript

Friends, I put my own spin on the CSS dropdown. This is like nothing I have seen on this forum to date. I think many of you will enjoy it. A lightning fast dynamic CSS driven submenu system that uses no JavaScript and only CSS files.

Code: Select all

<----------------CREATE-------------->
inc_script/frontend_render/css_dropdown.php
<---------------------------------------->

<--------------OPEN------------------>
write file: inc_script/frontend_render/css_dropdown.php

<?php 
  $content['all'] = str_replace('{DROPDOWN}', build_dhtmlmenu(0, 'level', ''), $content['all']); 
?>
<----------------CLOSE--------------->

<---------------OPEN------------------>
write file: include/inc_front/front.func.inc.php

starts @ ln 2498:
function build_dhtmlmenu( ... ) {

edit ln 2535:
$s .= build_dhtmlmenu($key, $class, $activeclass, $counter+1); 

// comment: I added ', $activeclass,'  to recursively pass active class name if needed and to properly nest the $counter+1 to correspond to the function declaration.

edit ln 2541 - 2545:

2541  if($s) {
2542    $g  = "\n<ul";
2543    if($counter>=0 && $class) $g .= ' class="'.$class.$counter.'"';
2544    $g .= ">\n".$s."</ul>\n";
2545  }

// comment: I modified the nested if to check if the counter is 0 or higher and the class variable is not null (which it shouldn't if you are making this menu system work properly), then the <ul tag will get the class name passed to the function along with the level appended to it and the menu is built dinamically with levels declared as classes.

// comment: this resolves the issue I was having in the first place. 
<----------------CLOSE--------------->

<-------------DOWNLOAD------------>
file: csshover.htc
from: http://www.xs4all.nl/~peterned/csshover.html
to: phpwcms_template/inc_css/csshover.htc
<---------------------------------------->

<----------------CREATE-------------->
 phpwcms_template/inc_css/menyou_css.css
<---------------------------------------->

<---------------OPEN------------------>
write file: phpwcms_template/inc_css/menyou_css.css

/*------------------------ CSS DROPDOWN MENU REPLACEMENT TAG CSS -------------------- */
/* We must acknowledge the hard work of Peterned and Eric Meyer for setting the stage */
/* for this CSS driven, no-JavaScript menu system.  Report bugs to toszter@yahoo.com. */

/* In order for this to work properly, please download csshover.htc from Peterned:    */
/* http://www.xs4all.nl/~peterned/csshover.html                                       */
/* Place csshover.htc into your inc_css directory with this and the primary CSS file. */
/* BE SURE to @import a one-tag CSS file before declaring the body tag for your pages */
/* with this inside:                                                                  */

/* body { behavior: url(/phpwcms_template/inc_css/csshover.htc); }                                              */

/* Good luck.. Post your coments on the PHPWCMS FORUM: http://www.phpwcms.de/forum/   */

/* BEGIN Menu Definitions */
div#pageMenu {									/* PROPRIETARY: This is capital-B menu DIV tag */
  font: 10px Verdana, Arial, Helvetica, sans-serif;
  background: url(http://capital-b.com/picture/img_site/main_r2_c1.jpg) 0 0 no-repeat;
  height: 21px; 
  margin: 0px; 
  padding: 0px 0px 0px 70px; 
  white-space: nowrap;
  }
div#pageMenu ul {								/* 1st Level UL in the DIV [Inh] */
  margin: 0px;
	padding: 0px;
	background: white;						/* UL entire background */
	border: 1px solid #FF5809;		/* UL outer border */
	border-width: 0 1px;					/* UL top/bottom = 0; UL left/right = 1 */
  }
div#pageMenu li { 							/* 1st Level LI in the DIV **TOP ROW OF LINKS ONLY** [Inh] */
	z-index: 50;
  position: relative;						/* Allows for absolutely positioned children */
	list-style: none;  						/* Removes bullets */
	margin: 0px;									/* Removes all margins explicitly for Opera */
	float: left; 									/* We want the list items to line up horizontally */
	width: auto;									/* List items need to be the same width */
	line-height: 1em;
  }
div#pageMenu li:hover {					/* NO MISTAKE: apply hover effect to list items, not links */
  background: url(http://capital-b.com/picture/img_site/menu_bg_hover.jpg) 0 0 repeat-x;
  }
div#pageMenu ul ul {  					/* 2nd level UL in the DIV, child of 1st UL [Inh] */
  position: absolute;						/* Position nested UL at top of parent LI */
	width: 125px;									/* CHANGE WIDTH: ULs must be equal width to prevent breakage */
	display: none;								/* Hide any UL descending from a UL */
	}
div#pageMenu ul ul li {
  width: 125px;
  border-bottom: 1px solid #FF5809;
	}
div#pageMenu li a {							/* THIS affects top row structure elements only */
  position:relative;                         /*Prevents menus from displaying in old Safari */
  z-index: 151;
  display: block;								/* Each link has block level box like <p> or <div> */
	margin: 0px;
	padding: 4px 10px 5px 4px; 		/* width of the cells includes this right and left padding. */
	text-decoration: none;
	width: 100%;									/* Set a width for IE/Win bug fix */
  voice-family: "\"}\" ";	voice-family: inherit;
  width: 35px;									/* CHANGE WIDTH: Confuse old IE/Win; In top row links in new browsers*/
	}
div#pageMenu li li a {					/* THIS affects all subsequent elements in DROPDOWN list */
	padding: 4px 0px 5px 4px; 		/* width of the cells includes this right and left padding. */
	margin: 0px;
	width: 100%;									/* Set a width for IE/Win bug fix */
  voice-family: "\"}\" ";	voice-family: inherit;
  width: 121px;									/* CHANGE WIDTH: Confuse IE/Win; set width in good browsers*/
  }
div#pageMenu>ul a {							/* IE/Win Hack: this gets ignored by inferior browsers */
  width: auto;
	}
div#pageMenu ul.level1 li:hover ul.level2,
div#pageMenu ul.level2 li:hover ul.level3 {
  display: block;
	}
div#pageMenu ul.level2 {
  top: 19px;
	left: -1px;
	border-top: 1px solid #FF5809; 	/* top Border for the 1st sub menu. */
	}
div#pageMenu ul.level3 {
  top: -1px; 
	left: 125px;										/* CHANGE WIDTH: Controls where sub-sub menus appear */
	border-top: 1px solid #FF5809;  /* top Border for the 2nd sub menu. */
	}
/* END Menu Definitions */
<----------------CLOSE--------------->

<----------------CREATE-------------->
phpwcms_template/inc_css/csshover.css
<---------------------------------------->

<---------------OPEN------------------>
write file: phpwcms_template/inc_css/csshover.css

//repaired 3.3.05 bug reported by user cyrano.

body {
  behavior: url(/phpwcms_template/inc_css/csshover.htc);  
  }
<----------------CLOSE--------------->

<---------------OPEN------------------>
write file: phpwcms_template/inc_css/frontend.css

@import url("csshover.css");
@import url("menyou_css.css"); 
<----------------CLOSE--------------->

//COMMENT:  In your template, you should now use the replacement tag {DROPDOWN} inside a <DIV id="pageMenu"></DIV>

RESULTING HTML:

<div id="pageMenu">

<ul class="level1">
<li><a href="index.php?service">Service</a>
<ul class="level2">
<li><a href="index.php?id=16,0,0,1,0,0">Service Policy</a></li>
<ul class="level3">
<li><a href="index.php?id=20,0,0,1,0,0">1 - Determine Scope</a></li>
</ul>
</li>
<li><a href="index.php?id=18,0,0,1,0,0">Satisfaction</a></li>
</ul>
</li>
<li><a href="index.php?design">Web Design</a>
<ul class="level2">
<li><a href="index.php?id=14,0,0,1,0,0">FAQs</a></li>
</ul>
</li>
<li><a href="index.php?photo">Photography</a>
<ul class="level2">
<li><a href="index.php?id=15,0,0,1,0,0">FAQs</a></li>
</ul>
</li>
<li><a href="index.php?contact">Inquire</a></li>
</ul>
</div>
I am implementing this technique at http://www.capital-b.com which is created entirely using CSS, indeed a CSS Zen Garden.

I designed the menu to work with my files, obviously, and I did my best to comment the individual CSS attributes so that others can modify the styles with ease. This really uses no JavaScript and because the CSS is cashed, the setup loads rather quickly.

I've tried to make it as compatible with the latest browsers but I have not tested on Safari. This works great in both WinIExploder and FireFox so I gather it will work in Safari. At least from my previous experience, SAFARI renders nearly identically to FireFox.

A HUGE THANKS goes out to Eric Meyer and Peterned who made this possible. For more information about this and other very cool CSS techniques, I suggest eneryone visits Peterned's site, mentioned above, and buys Eric Meyer's More Eric Meyer on CSS.

Great appreciation also goes out to Ben at emergentmediagroup dot com for introducing phpwcms to me when I was busy re-inventing the wheel.

Please give me feedback on this technique and my site, though I know I've left the content for last.

Thank you all for this incredible product. :wink:

~toszter

Posted: Thu 3. Mar 2005, 16:45
by cyrano
hi,
first of all: thanx for the menu driven by css.

hmm, i checked your site - in Firefox it works, but not in IE and SlimBrower, which uses IE....

Tested on PC XP, IE 6.0.029 and firfox 1.0.1

Just me to see only in Firefox?

Posted: Thu 3. Mar 2005, 16:50
by toszter
I'm looking into it right now. Funny that it worked fine in my local machine.
I'll fix it and explain the solution.

~toszter :oops:

Posted: Thu 3. Mar 2005, 17:18
by toszter
cyrano wrote:hi,
first of all: thanx for the menu driven by css.

hmm, i checked your site - in Firefox it works, but not in IE and SlimBrower, which uses IE....

Tested on PC XP, IE 6.0.029 and firfox 1.0.1

Just me to see only in Firefox?
Here's what the problem was:
IEWin doesn't allow for behavior files to be accessed if they have an http://www.blah.foo/ prefix. The FILE PATH must be relative to the site root for the .htc file to be read by IEWin.

FireFox doesn't have a problem accessing htc files remotely.

Thank you very much for the call cyrano. The reason it worked on my machine locally was because I used a relative file path to the htc file.

~toszter :)

Posted: Thu 3. Mar 2005, 17:29
by Ben
Wow, this looks great, toszter! I think I may have found a small issue with file naming:

Shouldn't these two filename references be the same?

<----------------CREATE-------------->
phpwcms_template/inc_css/menyou_css.css
<---------------------------------------->

<---------------OPEN------------------>
write file: phpwcms_template/inc_css/frontend.css

@import url("csshover.css");
@import url("your_menyou.css");
<----------------CLOSE--------------->

I haven't tried it, yet, but I suspect the filenames should be the same. Great work!