We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15923
    • 9 Posts
    Hello to All,
    I’m new to ModX and have just started with my first page. Everything is going great sofar, i just cant get 2 things to work.

    My first Problem is the Wayfinder. I want active Points in the Menu to be highlighted. So i added

    .active a {
      color: #B7274C;
    }
    


    to my CSS. This works fine until i have a Menu point with to Submenus. When i click any of the menupoints (e.g. the parent or one of the children) all of them are red.
    How can I highlight just the actual active link.


    The second problem is that i want a random image in my headder.

    I have a folder in modx/assets/templates/mypage.tld/assets/img/bg.

    <?php
    // get images from bg image directory
    if ($handle = opendir('./assets/templates/mypage.tld/assets/img/bg')) {
        $i = 1;
        while (false !== ($file = readdir($handle))) {
            if (substr($file, 0, 1) != ".") {
             $images[$i] = $file;
             $i++;  
            }       
        }
        closedir($handle);
    } 
    
    //return a random filename
    $randomimage = rand(1, count($images));
    return $images[$randomimage];
    ?>
    


    Than I use this and make it a snippet

    I make a TV called RandomImage

    and add this to my my CSS.

    #picture {
      width: 480px;
     background: url(./assets/templates/mypage.tld/assets/img/bg/[!RandomImage!]) no-repeat;
    }
    



    But all I get is a white space in my page. If it helps my folder structure ist modx/assets/templates/mypage.tld/assets and in assets i’ve got a folder for all the pictures used and a folder /style where i store my css file.

    The snippet is from here. http://modxcms.com/forums/index.php?topic=37419.0


    I hope somebody can help me. Besides these minor problems everything is great sofar smiley...

    Greetings Kingslayer

    €: Forgot to mention, I use ModX Evo 1.0.5.
      • 33968
      • 863 Posts
      For your ’red links’ issue, the problem is that because all the submenu <a> elements are nested within the ’.active a’ element, they inherit its formatting.

      You could get around that by inserting this underneath the existing css:
      .active li a {
        color: blue;
      }
      Replace ’blue’ with your default link colour.

      As for the random image, you need to include that css in your actual page template, not in your css file. Evo doesn’t parse css files. Also there was a typo in your url which I’ve corrected below. Add this between the <head></head> files in your page template:
      <style type="text/css">
      #picture {
          width: 480px;
          background: url(assets/templates/mypage.tld/assets/img/bg/[!RandomImage!]) center no-repeat;
      }
      </style>


      If that doesn’t work, test the image path by pasting this into your browser (replace yoursitename, imagename, etc):
      www.yoursitename.com/assets/templates/mypage.tld/assets/img/bg/imagename.jpg
        • 15923
        • 9 Posts
        Thank you ! Works like a charm =).

        Bit if set the .active for li to standart color i cant highlight the submenus if i click them =/.
          • 33968
          • 863 Posts
          Do you mean when you hover over the links they do not highlight?

          I’m not sure exactly what you mean but you could try something like
          .active li a:hover { 
              color: green; 
          }

          (insert under the previous css I gave you)
            • 15923
            • 9 Posts
            Thanks now everything is fine. It’s not exactly the way I wanted it but its allright =).

            The Structure is:

            Home
            Sub1
            Sub2
            Blog
            Sub1
            Sub2

            and so on...

            I wanted Home to be highlighted when klicked, but when i click sub1 in Home i wanted Home not to be highlighted but Sub1 to be highlighted. But i think this is not possible...
              • 33968
              • 863 Posts
              With modx, anything is possible laugh

              You can certainly do it, without seeing your site it’s a little hard to suggest something. Have a look at the Wayfinder CSS Class Parameters

              You should be able to do it using &here and &self
                • 15923
                • 9 Posts
                Can i adress these in the css file ?

                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml">
                
                <head>
                <meta name="description" content="[*description*]" />
                <meta name="robots" content="index, follow" />
                <meta name="revisit-after" content="14 days" />
                <meta name="identifier-url" content="[(site_url)]" />
                <meta name="content-language" content="de" />
                <meta http-equiv="expires" content="0" />
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <base href="[(site_url)]" />
                <title> [*pagetitle*] | [(site_name)]</title>
                <link rel="stylesheet" type="text/css" href="[(base_url)]assets/templates/domain.tld/assets/style/default.css"
                <style type="text/css">
                #picture {
                    width: 480px;
                    background: url(assets/images/bg/[!RandomImage!]) center no-repeat;
                }
                </style>
                </head>
                
                <body>
                
                  <div id="wrapper">
                    <div id="header">
                      <div id="info"></div>
                    <div id="picture"></div>
                      <div id="logo"></div>
                    </div>
                    
                    <div id="mid">
                      <div id="sidebar">
                [[Wayfinder?startId=`0` &level=`2 &hideSubMenus=`TRUE`]]
                </div>
                        <div id="content">
                         [*content*]
                       </div>  
                    </div>
                    
                  </div>
                    <div id="footer">
                      <div id="footerleft"></div>
                      <div id="footerright">
                        © 2011 
                        <a href="[~7~]"> Impressum</a> <a>  | </a>
                        <a href="[~8~]"> Kontakt </a>
                      </div>
                    </div>
                  <div id="shadowbottom"></div>
                </body>
                </html>
                

                body,* {
                  margin:0;
                  padding:0;
                  font-family:"Arial","Sans-Serif";
                  color:#333333;
                }
                
                body {
                  background: #fff;
                }
                
                h1, h2 {
                  margin-top: 10px;
                  margin-bottom: 20px;
                  font-weight: normal;
                }
                
                h1 {
                  font-size: 200%;
                }
                
                h2 {
                  font-size: 150%;
                }
                
                h3 {
                  font-size: 100%;
                  margin-bottom: 10px;
                }
                
                a {
                  outline: none;
                  text-decoration: none;
                }
                
                p {
                  margin-bottom: 20px;
                  line-height: 1.8em;
                }
                
                a:hover {
                  color: #B7274C;
                  margin-left: 3px;
                }
                
                .active a {
                  color: #B7274C;
                }
                
                .active li a {
                  color: #333;
                }
                
                
                .active li a:hover {
                  color: #B7274C;
                }
                
                #shadow {
                  background: url(../img/shadow_bottom.jpg) repeat-x;
                }
                
                #wrapper {
                  height: 100%;
                  width: 995px;
                  margin: 0px auto 0px auto;
                  padding: 0px 19px 0px 13px;
                  background: url(../img/shadow.jpg)  repeat-y;
                }
                
                #header {
                  position: relative;
                  height: 170px;
                }
                
                #header div {
                  height: 170px;
                  float: left;
                }
                
                #info {
                  width: 185px;
                  background: url(../img/info.png) no-repeat;
                }
                
                /* -------------------------------------------------------------------------------------------------------------------
                Normales Headerbild, jetz mit Snippet "RandomImage" direkt im Template eingebunden.
                ----------------------------------------------------------------------------------------------------------------------
                #picture {
                  width: 480px;
                 background: url(../img/pic_head.jpg) no-repeat;
                } */
                
                #logo {
                  width: 330px;
                  background: url(../img/logo.jpg) no-repeat;
                }
                
                #mid {		
                  position: relative;
                  overflow: hidden;
                  background: url(../img/kontur.png) no-repeat right bottom #B6B6B6;
                }
                
                #sidebar {
                  padding: 25px 0px 25px 15px;
                  width: 170px;
                  background-color: transparent;
                  float: left;
                }
                
                #sidebar ul {
                  list-style: none;
                  position: relative;
                  font-size: 18px;
                  width: inherit;
                }
                
                #sidebar ul li {
                  margin-bottom: 10px;
                }
                
                #sidebar ul li ul {
                  margin-top: 5px;
                  margin-left: 5px;
                  left: 10px;
                  font-size: 15px;
                }
                
                #content {
                  padding: 25px 45px 50px 25px;
                  float: left;
                  min-height: 500px;
                  width: 740px;
                  font-size: 15px;
                  background: url(../img/kontur.png) no-repeat right bottom #CCC;
                }
                
                #footer {
                  position: relative;
                  height: 30px;
                  width: 995px;
                  margin: 0 auto;
                  padding: 0 19px 0 13px;
                  top: -15px;
                }
                
                #footer div {
                  height: 20px;
                }
                
                #footerleft {
                  float: left;
                  width: 175px;
                  background-color: #B7274C;
                  padding: 5px;
                }
                
                #footerright {
                  float: left;
                  width: 770px;
                  background-color: #666;
                  color: #fff;
                  font-size: 12px;
                  padding: 8px 15px 2px 25px;
                }
                
                #footerright a {
                  color: #fff;
                  float: right;
                  padding-left: 20px;
                }
                
                #footerright a:hover {
                color: #B7274C;
                }
                
                #shadowbottom {
                  background: url(../img/shadow_bottom.jpg) no-repeat;
                  margin: 0 auto;
                  height: 34px;
                  width: 995px;
                  top: -30px;
                  padding: 0px 19px 0px 13px;
                  z-index: -1;
                  position: relative;
                }
                


                If it helps this is my page !


                  • 15923
                  • 9 Posts
                  My Snippet doesnt Seem to work in Opera and Chrome both dont show the Image just the link to the background graphic ... /fixed forgot to close a breaket...


                  I now have the Menu working i added

                  [[Wayfinder?startId=`0` &level=`2 &hereClass=`selected` &selfClass=`else` &hideSubMenus=`TRUE` ]]


                  and i added this in my stylesheet

                  .else a{
                    color: #B7274C;
                  }
                  
                  .else li a {
                  color:#333;
                  }

                  which doesnt quite work jet, but thats just a logic problem that i cant figure out atm... It now highlights the right menu points but if it highlights the submenu points it doesnt highlight the parent menu point.

                  Hopefully i will figure that out tonight laugh..
                    • 33968
                    • 863 Posts
                    Not sure exactly what you mean but &hereClass will apply ’.active’ to the current document and all of it’s parents too. You can use &selfClass to target just the current document.

                    If you can link to a working example I can help you troubleshoot that, otherwise good luck!
                      • 15923
                      • 9 Posts
                      Thanks you for all the Help i figured it all out now smiley.

                      If it helps anyone i will just post my solution here ...

                      This is my Wayfinder

                      [[Wayfinder?startId=`0` &level=`2 &hereClass=`selected` &selfClass=`else` &hideSubMenus=`TRUE` ]]


                      and this the CSS Styles i use.

                      .selected.else a{
                        color: #B7274C;
                      }
                      
                      .selected.else li a{
                        color: #333;
                      }
                      
                      .selected a {
                      color: #B7274C;
                      }
                      
                      .selected li a {
                        color: #333;
                      }


                      Now if u click a Parent its highlighted Red. If you click a Child It and the Parent is highlighted red.