We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21092
    • 54 Posts
    Hey everyone,
    I have been having trouble figuring out how to do this. My website www.katskinner.com has a html/css navigation system.
    Rather than try to explain how it appears, please just look at the attached image:

    The HTML code for this is:
    		<div id="navigation">
    			<div id="nav_container">
    				<ul id="nav"> 
    					<li id="nav_about"><a href="/coming_soon">About</a> 
    					</li> <!-- close nav_about -->
    				  
    					<li id="nav_writing"><a href="/coming_soon">Writing</a> 
    						<ul> 
    							<li class="themes"><a href="/coming_soon">Books</a></li> 
    							<li class="wallpapers"><a href="/coming_soon">Lessons</a></li> 
    							<li class="tutorials"><a href="/forums/">Forums</a></li> 
    						</ul> 
    				  
    					</li> <!-- close nav_writing -->
    			  
    					<li id="nav_blog"><a href="/blog/">Blog</a>
    					</li> <!-- close nav_blog -->
    			  
    					<li id="nav_portfolio"><a href="/coming_soon">Portfolio</a> 
    						<ul> 
    							<li class="web"><a href="/coming_soon">Web</a></li> 
    							<li class="illustration"><a href="/coming_soon">Illustration</a></li> 
    						</ul> 
    				  
    					</li> <!-- close nav_portfolio -->
    			  
    					<li id="nav_store"><a href="/coming_soon">Store</a> 
    						<ul> 
    							<li class="cart"><a href="/coming_soon">cart</a></li> 
    						</ul> 
    				  
    					</li> <!-- close nav_store -->
    			   
            			<li id="nav_user"><a href="/coming_soon">User</a> 
    						<ul> 
    							<li class="account"><a href="/coming_soon">Account</a></li> 
    							<li class="logout"><a href="/coming_soon">Logout</a></li> 
    						</ul>
    				   
    					</li> <!-- close nav_user -->
    				
    				</ul> <!-- close "nav" -->
    			</div> <!-- close div "nav_container" -->		
    		
    		</div><!-- close div "navigation" -->
    		<!-- finish the navigation here -->
    


    The CSS Code for this is here:
    #navigation{
    	background-color: #492a01;
    	background-image: url(assets/components/KatSkinnerTheme/images/footer_bg.jpg);}
    	
    #nav_container{
    	margin: 0 auto;
    	width: 50em;
    	height: 150px;
    	}
    	
    #nav {
    	top: 15px;
    	margin: 0;
    	padding: 0;
    	list-style: none;
    	float:;
    	position:relative;
    	}
    
    #nav li {
    	margin: 0 10px 0 0;
    	padding: 0;
    	font: small-caps 30px "Times New Roman", Times, serif;
    	float: left; /* make this right and it will reverse order */
    	}
    
    #nav ul {
    	margin: 0px 0p 0;
    	padding: 0;
    	list-style: none; /*this adds dots to the list style on all sub-navigation items */}
    	
    #nav ul li {
    	margin: 0px 0 2px 0px;
    	padding:0px;
    	font: italic normal 16px "Times New Roman", Times, serif;
    	text-transform: lowercase;
    	text-align: left;
    	float: left; /* this ensures all sub-navigation items are aligned. by floating to right will align all items with the right of the main navigation text*/}
    
    #nav #nav_blog {width: 88px;}
    	
    #nav #nav_store {width: 88px;}
    	
    #nav #nav_user {width: 88px;}
    	
    #nav #nav_about {width: 100px;}
    	
    #nav #nav_portfolio {width: 130px;}
    	
    #nav #nav_writing {width: 107px;}
    	
    #nav a {
    	text-decoration: none;
    	color: #ffffff;}
    	
    #nav a:hover {
    	text-decoration: none; /*originally set to underline */
    	background-image:url(assets/components/KatSkinnerTheme/images/underline_white.png);
    	background-position: bottom center;
    	padding-bottom:2px;
    	white-space:nowrap;
    	background-repeat:no-repeat;}
    
    #nav ul a {
    	padding-left: 16px;
    	background: url() no-repeat -20px 0;}
    	
    #nav ul a:hover {text-decoration: underline;}
    	
    #nav .rss a:hover {
    	background-position: 0 5px;
    	background: url() no-repeat -20px 0;}
    	
    #nav .account a:hover {
    	background-position: 0 5px;
    	background: url() no-repeat -20px 0;}
    	
    #nav .twitter a:hover {background-position: 0 -54px;}
    	
    #nav .who a:hover {background-position: 0 -114px;}
    	
    #nav .contact a:hover {background-position: 0 -172px;}
    
    #nav .facebook a:hover {background-position: 0 -192px;}
    
    #nav .twitter a:hover {background-position: 0 -192px;}
    	
    #nav .web a:hover {background-position: 0 -233px;}
    	
    #nav .illustration a:hover {background-position: 0 -295px;}
    	
    #nav .themes a:hover {background-position: 0 -352px;}
    
    #nav .wallpapers a:hover {background-position: 0 -414px;}
    
    #nav .tutorials a:hover {background-position: 0 -474px;}
    
    #nav .cart a:hover{background: url() no-repeat -20px 0;}
    
    #nav #nav_about ul li {
    	width: 100px;
    	padding-top:5px;}
    
    #nav #nav_writing ul li {
    	width: 100px;
    	padding-top:5px;}
    	
    #nav #nav_blog ul li {
    	width: 100px;
    	padding-top:5px;}
    	
    #nav #nav_portfolio ul li {
    	width: 100px;
    	padding-top:5px;}
    
    #nav #nav_store ul li {
    	width: 100px;
    	padding-top:5px;}
    
    #nav #nav_user ul li {
    	width: 100px;
    	padding-top:5px;}
    


    How would I code the same thing in Wayfinder to appear the same (including the css if it changes). Please note that not all "sub-topics" of my website are in containers within the document tree the same (e.g. "forums" is actually found at www.katskinner.com/forums/ rather than www.katskinner.com/writing/forums/. Can this even be done???
      Visit www.katskinner.com for all your expert novel writing tips, tutorials and more.
    • Please note that not all "sub-topics" of my website are in containers within the document tree the same (e.g. "forums" is actually found at www.katskinner.com/forums/ rather than www.katskinner.com/writing/forums/. Can this even be done???

      You can make that work by making a weblink in the ’writing’ container to your forums.

      I don’t have the exact wayfinder calls and css at hand right now, but to give you some pointers to start off with:

      - You want to search through 2 levels (the containers and one level of subs)
      - The standard output will render that as such...
      <ul><li>Writing <ul><li>Forum</li><li>Themes</li></ul></li><li>Second container</li></ul>


      You’d use something like this for your CSS:
      #nav ul li { //styling of the container links eg writing, don't forget display:inline }
      #nav ul li ul li { //styling of the child documents, using display: block to show it under each other }


      When I have more time I’ll see if I can come back on this, but now you may be able to figure out how to do it.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 18856
        • 12 Posts
        All right, so to begin with you need to make sure you have your structuring correct. When using Wayfinder the easiest way to get it displaying the correct elements under the correct sections is to make sure you have the proper hierarchy setup from the get go.

        Here’s an example:


        • Home
        • About
        • Writing Blog
        • Portfolio
        • Store
        • User

        Your root structure should look similiar to this. Anything that is not an actual document can be set as a weblink. "Writing" section will act as a container and you would have "books, lessons and forums" underneath it. Same with all the other sub-sections, please note this works exactly the same with weblinks.

        You can go check out an example I threw together using your image and css for a base, this is about as simple and dirty as I could make it for lack of time. Expand the window and should look pretty close to what you were trying to do.

        http://mbixby.com/wayfinder-test.html

        Here’s the HTML and Wayfinder call I used:

        <div id="nav">
            [!Wayfinder? &startId=`0` &levelClass=`lvl`!]
        </div>
        


        ...and here’s the CSS:
        #nav {
        	overflow: auto;
        	background-color: #492a01;
        	padding: 20px 0;
        	width: 100%;
        }
        
        /* == Nav Universal Elements == */
        #nav ul {
        	margin: 0;
        	padding: 0;
        	list-style: none;
        }
        	
        	#nav ul li a {
        		color: #FFF;
        		text-decoration: none;
        		font: small-caps bold 30px "Times New Roman", Times, serif;
        	}
        	#nav ul li a:hover {
        		text-decoration: underline;
        	}
        
        /* == 1st Level Nav Items == */
        #nav ul li.lvl1 {
        	float: left;
        	position: relative;
        	padding: 0 20px;
        }
        
        /* == 2nd Level Nav Items == */
        #nav ul li.lvl1 ul {
        	margin-left: 15px;
        }
        	#nav ul li.lvl2 a {
        		font-size: 16px;
        		font-style: italic;
        		font-weight: normal;
        		padding: 5px;
        	}
        		
        


        Once you get it displaying somewhat correctly, then it’s just tweaking the font-sizes and <li> padding to get it to fit nicely in your layout. It doesn’t have to be perfect, it just has to be usable, I will take a usable navigation over one that "looks cool" anyday.

        If you have any other questions/comments don’t hesitate to ask.

        Good luck!
          • 21092
          • 54 Posts
          Thanks so much for the help, I’ve now got the navigation system showing perfectly laugh
          @mbixby, just for my own understanding, whats the ".lvl1" and ".lvl2" bits do in the CSS? Does this interact with the wayfinder output by any chance??

          @markieham, thanks for the tip about the weblink, I will have to try that.

          I did start liking the initial placement of Forums in the navigation bar by itself, including the children of "login","register" and "search", however I noticed once logged in that those children never changed. (Is this a problem with discuss or wayfinder?) I will probably do the weblink to the forums under the writing area and select hide the forum from menus tickbox for the moment. However, if the children navigation links are a wayfinder issue, how would i go about fixing that?

          I was really struggling to get it to work before you answered, so again thank you so much.
            Visit www.katskinner.com for all your expert novel writing tips, tutorials and more.
          • Hey Kathleen,

            The ’lvl1’ and ’lvl2’ classes come from the Wayfinder call, namely: &levelClass=`lvl`.
            mbixby’s method is slighly different then what I suggested, as his solution focuses on the classes, and mine would apply more generally to UL’s within another UL’s LI.


            What do you mean by the links never change when logged in? That the link "Login" remains when you are already logged in on the forum?

            In order to change those links, you’d have to sync your forum with the website by building a snippet that checks if you are logged in, and shows the relevant links.

            If your forum is made up from documents which have comments on it, and users are webusers from MODx, there are snippets which check if a user is part of a certain membergroup, and changes the output accordingly. I’ll see if I can track it back for you.

            Edit:
            Found it, it’s called Personalize (http://modxcms.com/extras/package/335). It checks if a user is logged on or not.
            In the repository it’s stated as being for Revo and as such it comes as a package. I managed to find an older version installed on a evo 1.0.0 install of MODx somewhere, see below.

            If you’d use something like this, I’m not sure how you can combine it with Wayfinder’s automatic menu, except for using &excludeDocs to exclude the weblinks to login/register etc, and putting the Personalize snippet after the wayfinder one to have those links (in the relevant chunks) shown at the right.

            <?php
            #::::::::::::::::::::::::::::::::::::::::
            # Snippet Name: Personalize 
            # Short Desc: calls a chunk if the user is logged in, otherwise calls another
            # Version: 2.0
            # Created By: 	Ryan Thrash ([email protected]), and then
            #		powered up by kudo ([email protected])
            #
            # Date: Aug 03, 2006
            #
            # Changelog: 
            # Dec 01, 05 -- initial release
            # Jun 19, 06 -- updated description
            # Jul 19, 06 -- hacked by kudo to output chunks
            # Aug 03, 06 -- added placeholder for username
            #
            #::::::::::::::::::::::::::::::::::::::::
            # Description: 	
            #	Checks to see if webusers are logged in and displays yesChunk if the user
            #	is logged or noChunk if user is not logged. Insert only the chunk name as
            #	param, without {{}}. Can use a placeholder to output the username.
            #	TESTED: can be used more than once per page.
            #	TESTED: chunks can contain snippets.
            #	
            #	
            # Params:
            #	&yesChunk [string] [REQUIRED]
            #		Output for LOGGED users
            #
            #	&noChunk [string] [REQUIRED] 
            #		Output for NOT logged users
            #
            #	&ph [string] (optional) 
            #		Placeholder for placing the username
            #		ATTENTION!: place this ph only in yesChunk!
            #	
            #
            # Example Usage:
            #
            #	[[LoggedOrNot? &yesChunk=`Link` &noChunk=`Register` &ph=`name`]]
            #
            #	Having Chunks named {{Link}} and another {{Register}}, the first will be
            #	published to registered user, the second to non-registered users.
            #
            #::::::::::::::::::::::::::::::::::::::::
            
            # prepare params and variables
            $o = '';
            $yesChunk = (isset($yesChunk))? $yesChunk : '';
            $noChunk = (isset($noChunk))? $noChunk : '';
            
            # do the work
            $test = $modx->getLoginUserName();
            if ($test) {
                $o = $modx->getChunk($yesChunk);
              } else {
                $o = $modx->getChunk($noChunk);
            }
            
            if (isset($ph)) {
            	$modx->setPlaceholder($ph,$test);
            	return $o;
            } else {
            	return $o;
            }
            ?>
              Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

              Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
              • 18856
              • 12 Posts
              If you’d use something like this, I’m not sure how you can combine it with Wayfinder’s automatic menu, except for using &excludeDocs to exclude the weblinks to login/register etc, and putting the Personalize snippet after the wayfinder one to have those links (in the relevant chunks) shown at the right.

              I’m not actually testing this on the fly, but here is a brief overview of a possible solution.

              All right, let’s modify our Wayfinder call, we are going to add to parameters to it, &outerTpl and &innerTpl:
              <div id="nav">
                  [!Wayfinder? &startId=`0` &levelClass=`lvl` &outerTpl=`navOuterTpl` &innerTpl=`navInnerTpl`!]
              </div>
              


              The &outerTpl is a chunk designating the wrapper for the lvl1 <li>’s when Wayfinder builds out menu:
              Create chunk named, navOuterTpl.
              <ul id="nav">
                  [+wf.wrapper+]
                  [[LoggedOrNot? &yesChunk=`loggedIn` &noChunk=`` &ph=`name`]]
              </ul>
              


              The &innerTpl designates the wrapper for anything lower than lvl1 you don’t want id="nav" to repeat in all the secondary levels. Also we want to get rid of the Personalize call:
              Create chunk name, navInnerTpl
              <ul>
                  [+wf.wrapper+]
              </ul>
              


              Now you need to do the chunk for the Personalize snippet, this is simplified, may have to customize accordingly:
              Make new chunk named, loggedIn, pretty much just copying what Wayfinder is spitting out but putting it into a chunk.
              <li class="lvl1"><a href="">User</a>
                  <ul>
                      <li class="lvl2"><a href="">Login</a></li>
                      <li class="lvl2"><a href="">Account</a></li>
                  </ul>
              </li>
              


              Something like that should work. I’m not sure what you are trying to accomplish, but the above setup should hide the entire "User" category if you are not logged in. Normally I would make a wayfinder config php file to do something like this, a lot more flexibility and less chunks, but that’s for another time and place.

              Hope this was helpful.
                • 21092
                • 54 Posts
                Hey!

                Thanks for the replies, I am going over them now.
                Sorry I wasn’t clear about what I said earlier - let me try restating to see if it helps (its in relation to the forum sublinks).

                When a visitor views my website they see in the navigation (see nonmember.jpg attachment):
                -Home
                - About
                - All sublinks
                - Forums
                - Login
                - Register
                - Search
                - ETC

                However when a user logs into the site they see in the navigation (see loggedin.jpg attachment):
                -Home
                - About
                - All sublinks
                - Forums
                - Login
                - Register
                - Search
                - ETC

                As you may see, the Forum still shows "Login" and "Register" even when a user is logged in (in fact the entire navigation is exactly the same). That was the part of the navigation I was hoping to be different when logged in vs not-logged in.
                Ideally, the code should tell when a user is logged in and show only the "search" option, rather than "login","register" and "search". I will try to implement the solutions you have already provided in order to do this (I think the easier way to do this via code is to hide the login and register options if user is logged in), but if you can provide any help it would be greatly appreciated as this is my first real project within modx and dealing with coding in general (other than really basic html and css).

                Thank you so much for the help you have already provided, I am learning so much laugh Hopefully I’ll be able to do it all soon without any help

                Edit: I thought I might just mention that I’m using Revolution, and the forums are made with Discuss.
                  Visit www.katskinner.com for all your expert novel writing tips, tutorials and more.
                  • 53626
                  • 1 Posts
                  Very helpful thread.

                  Our site best vacuums for pet hair had the same issue.

                  Thanks [ed. note: lindag2 last edited this post 6 years, 8 months ago.]
                    • 3749
                    • 24,544 Posts
                    What I usually do is take the Login and Register options out of the menu (check "Hide from Menus" for them). Then use the Personalize snippet or custom code to show them only to not-logged-in users.

                    [ed. note: BobRay last edited this post 6 years, 9 months ago.]
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting