Jump to content

RopeADope

Members
  • Posts

    157
  • Joined

  • Last visited

Posts posted by RopeADope

  1. This navigation is my first trial into JavaScript so I may be thinking about it the wrong way.  I'm attempting a 3 tier navigation menu.  Without the delay, the 2nd tier will disappear when you mouseoff the 1st tier.  So my thought was to add a delay so you could make it to the second tier and subsequently the 3rd tier.  The reason for the clearTimeout was so that the divs don't stack when you mouseover different divs.  One thing that I've noticed however is that when you mouseover a 2nd or 3rd tier, they disappear before you can click a link anyway.  So I guess what I really need is a was to say "if the mouse is on a parent div, set the child div to be visible".  Which is sort of what I have now, but particularly on the 3rd tier, I need to keep the second tier menu from closing.  As you can probably tell, this is quite a task considering I've never really done any JavaScripting.  Any help would be great!

  2. Hi all.

     

    I'm getting some really weird behavior from a navigation menu.  When I go to the initial page, it displays as a list and everything is overlapping.  When I click a link, it displays as multiple tiers like its supposed to.  This doesn't happen every time so I can't figure out what the issue is.  Also, if I click the same link a bunch of times, every 2nd or 3rd click sends the menu to a list format then back to rows.  I feel like I might've missed something in the code but for the life of me, I can't find it.  Pertinent code is below...

    .tier{
       position:relative;
       display:block;
       padding-bottom:3px;
       width:100%;
       height:2em;
       line-height:2em;
       font-size:1em;
       background:transparent url('../images/nav_tier_tile.jpg') repeat-x top left;
       border-bottom:#000 solid 1px;
    }
    .subtier{
       position:relative;
       padding-bottom:3px;
       width:100%;
       height:1.6em;
       line-height:1.6em;
       font-size:0.8em;
       background:transparent url('../images/nav_subtier_tile.jpg') repeat-x top left;
       border-bottom:#000 solid 1px;
    }
    .subtier a:link,a:active,a:visited, .tier a:link,a:active,a:visited{
       display:table-cell;
       padding-left:1em;
       padding-right:1em;
       font-family:sans-serif;
       text-decoration:none;
       color:#000;
       text-shadow:1px 1px #eee;
    }
    .subtier a:hover, .tier a:hover{
       background-color:#eee;
       color:#000;
       border-bottom-left-radius:1em;
       border-bottom-right-radius:1em;
    }

     

    Tier 1

    <div class="tier">
    <a href="/index.php">Home</a>
    <a href="/demand_management/">Demand Management</a>
    <a href="/engineering/">Engineering</a>
    <a href="/steady_state/">Steady State</a>
    <a href="/communications/">Communications</a>
    <a href="/business_management/">Business Management</a>
    <a href="/risk_management/">Risk Management</a>
    <a href="/other/">Other</a>
    </div>

     

  3. So something like this?

          <script language="Javascript" type="text/javascript">
    	function show(id){
    		if(t!=''){
    			clearTimeout(t);
    		}
    		document.getElementById(id).style.display = 'block';
    	}
    	function hide(id){
    		t=setTimeout("document.getElementById('" + id + "').style.display = 'none'",1000);
    	}
          </script>

     

    EDIT: Tried this and it permanently puts the sub-divs on the page...they never time out.  Also, the first div that I roll over to show a subdiv, doesn't work.  For some reason, it works on the second div I roll over, then when i roll over the first one again it will show the sub div.

  4. Hi all.

     

    Just working on something simple to show/hide navigation divs.  Here's what I have so far...

          <script language="Javascript" type="text/javascript">
    	function show(id){
    		if(t!=''){
    			clearTimeout(t);
    		}else{
    			document.getElementById(id).style.display = 'block';
    		}
    	}
    	function hide(id){
    		var t=setTimeout("document.getElementById('" + id + "').style.display = 'none'",1000);
    	}
          </script>

     

    The problem that I'm having is that the clearTimeout(t) seems to prevent anything from showing.  If I comment it out, everything works fine.  Ideally, the point of the clearTimeout bit was to clear any remaining time when you mouseover another item.

     

    Tips on fixing that problem and improving this script would be greatly appreciated!

     

  5. Hi all.

     

    I'm looking to make a 3 level navigation menu.  Each level will open when you mouseover the previous level.  e.g. mouseover level 1 link shows level 2 links, mouseover level 2 link shows level 3 links.

     

    I have no idea where to start with this.  Any resources or starting code would be a huge help.

  6. Hi all.

     

    I've got this bit of code:

       $needles=array(`.`,`..`,`css`,`php`,`input_forms`);
    
       $t1=scandir($_SERVER['DOCUMENT_ROOT']);
       foreach($t1 as $t1_value){
          if(!is_dir($t1_value)){
             unset($t1[array_search($t1_value,$t1)]);
          }else{
             unset($t1[array_search($needles,$t1)]);
          }
       }
    

     

    As you can see, I'm trying (in the else statement) to array search $t1 for everything in $needles, then unset the matches from $t1.  But its not working and I'm not sure why.  I also tried...

    unset($t1[array_search(in_array($needles,$t1),$t1)]);
    

     

    But that doesn't work either.  It only removes the "." directory from the array.  Any ideas on what's going wrong?

  7. Hi all.

     

    I'm trying to build a dynamic multiple tiered navigation menu that operates on the existence of directories.  So far, I have some code that will read through the document root, and one sub level of directories but I'm not sure how to get into the third level of directories.  Here's what I have so far...

     

    The code:

          $docroot=scandir($_SERVER['DOCUMENT_ROOT']);
    
          unset($docroot[array_search('.',$docroot)]);
    
          unset($docroot[array_search('..',$docroot)]);
    
          unset($docroot[array_search('php',$docroot)]);
    
          unset($docroot[array_search('css',$docroot)]);
    
          unset($docroot[array_search('input_forms',$docroot)]);
    
          $docroot=array_values($docroot);
    
          
    
          //Build tier 1
    
          echo "<div class=\"tier\">";
    
          echo "<a href=\"/index.php\">Home</a>";
    
          foreach($docroot as $value1){
    
             if(is_dir($value1)){
    
                $t2=scandir($_SERVER['DOCUMENT_ROOT'] . "/" . $value1);
    
                unset($t2[array_search('.',$t2)]);
    
                unset($t2[array_search('..',$t2)]);
    
                $t2=array_values($t2);
    
                $t1[]=$t2;
    
                
    
                echo "<a href=\"/$value1/\">";
    
                $value1=str_replace("_"," ",$value1);
    
                $value1=ucwords($value1);
    
                echo $value1;
    
                echo "</a>";
    
             }
    
          }
    
          echo "</div>";
    

     

    The output:

    [it automatically builds the first tier of the menu with some stylesheet definitions and places it here.  I did this just for testing purposes.]
    Array
    (
        [0] => Array
            (
                [0] => bus_mgmt_context.pdf
                [1] => financial_management
                [2] => index.php
                [3] => nav.php
                [4] => service_level_management
                [5] => service_portfolio
                [6] => workforce_management
            )
    
        [1] => Array
            (
                [0] => element_inventory
                [1] => index.php
                [2] => mobile_administration
                [3] => monthly_bill_review
                [4] => nav.php
            )
    
        [2] => Array
            (
                [0] => business_it_requests
                [1] => change_management
                [2] => demand_management_context.pdf
                [3] => index.php
                [4] => nav.php
                [5] => project_management
                [6] => release_management
            )
    
        [3] => Array
            (
                [0] => availability_management
                [1] => capacity_management
                [2] => configuration_management
                [3] => index.php
                [4] => nav.php
                [5] => planning
                [6] => problem_management
                [7] => system_planning
            )
    
        [4] => Array
            (
                [0] => context
                [1] => input
                [2] => reports
                [3] => sop
                [4] => t3.php
                [5] => video
            )
    
        [5] => Array
            (
                [0] => executive_reports
                [1] => index.php
                [2] => kpi_index
                [3] => nav.php
            )
    
        [6] => Array
            (
                [0] => compliance
                [1] => hipaa_definitions.pdf
                [2] => index.php
                [3] => information_security
                [4] => nav.php
                [5] => risk_context.pdf
                [6] => service_continuity
                [7] => threat_management
            )
    
        [7] => Array
            (
                [0] => incident_management
                [1] => index.php
                [2] => nav.php
                [3] => release_management
                [4] => service_desk
                [5] => service_requests
                [6] => supplier_management
            )
    
    )
    

  8. Hi all.

     

    I was looking for some tips on code optimization and came across a few resources.  However, I know nothing as of yet about code optimization so I'm not sure how legitimate these resources are.  Some confirmation would be very helpful along with any personal tips you may have.  Thanks in advance!

    http://www.wmtips.com/php/tips-optimizing-php-code.htm

    http://www.chazzuka.com/blog/?p=58(some redundancy from the first link is included here)

     

     

    Some Questions I Thought Up (Warning: may be ridiculous questions):

    1) Does excess white space (returns, space, tabs, etc.) in files affect performance for a large scale application (For an application that's ~500 files)?

    2) Does directory structure affect performance (e.g. 3 directories deep versus 10 directories deep)?

    Possibly more to come

     

     

  9. I have a pretty good base so far.  I have a script that reads all the directories in the DOCROOT and prints them as links (because all folders have an index.php).  My next step is to make it recursively go through the directories and subdirectories and subsequently put those into arrays to develop the 2nd and 3rd tiers of the menu.  I think I have to do some serious JavaScript research though because the menus have to appear onClick.  If you have any tips on that I'd appreciate it.

  10. Here's the full bit of code:

    $file=scandir($_SERVER['DOCUMENT_ROOT']);
    $matches=("zDash","php","xampp","wedding",".","..","css","input_forms");
    foreach($file as $value){
    if(is_dir($value)){
    	if(in_array($value,$matches){
    		echo "";
    	}else{
    		$value=preg_replace("/_/"," ",$value);
    		$value=ucwords($value);
    		echo "<a href=\"/$value/\">" . $value . "</a>";
    	};
    };
    };
    

     

    Any ideas why its not working?

  11. That worked.  Just out of curiosity, can I use an array as a comparison argument?

     

    e.g.

    $matches=array("php","css");
    
    if($value==$matches){
        Do stuff...
    }
    

     

    If not, is there a way to compare $value to several values in an array?  Long term, I'm thinking about putting the names of the directories to show into a MySQL table and match against those names.  The software that this will be in will have different folders to show based on the client so I'll need a way to delineate which folders to show.

  12. Hi all.

     

    I have the following function to display directories but I need help to reverse my logic and develop a proper expression.

    if(preg_match("/[.]/i",$value)){
    echo "";
    }else{
    echo $value . " ";
    };
    

     

    What I need it to do is check if $value is a directory and echo the directory name, else echo nothing.  Right now I have it backwards (not supposed to check for a negative condition right?).  What would the regex expression look like to show all directories AND exclude certain directories?  I tried...

    preg_match("/[.][code=php:0][css]/i",$value)
    

    But this printed out nothing.  The directories "php" and "css" are the ones I don't want echo'ed to the screen.

  13. Hi all.

     

    I'm working on a project that requires a 3 tier navigation menu that's dynamic and I'm not quite sure where to start with it.  The structure of the menu is like so...

     

    A unique list of Parent-Modules

    Tier1: Parent-Module1

     

    Each parent module has a second tier menu that appears upon clicking a parent module.  Each parent module has a unique list of tier 2 sub modules

    Tier 2: Sub-Module1  -  Sub-Module2

     

    Each sub module has a third tier menu that appears upon clicking a sub module.  Each sub module has a unique list of tier 3 child modules

    Tier 3: Child-Module1 -  Child-Module2 -  Child-Module3

     

    A visual:

    Parent (each parent module has this structure)

    |

    |--------Sub Module

    |            |-Child Module 1

    |            |-Child Module 2

    |            |-Child module 3

    |--------Sub Module

    |            |-Child Module 1

    |            |-Child Module 2

    |            |-Child module 3

    |--------Sub Module

                  |-Child Module 1

                  |-Child Module 2

                  |-Child module 3

     

    Every tier has to be dynamic as the module names/locations are often changed.  My thought is to use opendir/readdir in order to build the tiers based on what files exist, but I'm not sure if this is a safe/reliable practice.  Any input would be a great help.

     

    EDIT: The navigation links would have to have "pretty" names (e.g. Business Processes instead of business_processes).

  14. Hmmm.  I still feel a little fuzzy on when and where to implement OOP.  From what I've gathered here, it seems like both OOP and procedural have a time and place and both can be used concurrently.  I think the trouble I'm having is finding a good example of where OOP is more appropriate than procedural.  Any ideas/code examples?

  15. Hi all.

     

    I have this line of code that I found to do a search and replace.  It works perfectly on a single file but I need to do multiple files in multiple directories.  How do I go about doing that?  Is there a flag I can add to the line of code?  (I don't know anything about perl)

     

     

    perl -pi -w -e 's/search_string/replace_string/g;' *.php

     

  16. Hi all.

     

    I have some questions in reference to using OOPHP.  All of my programming thus far has been procedural and that's worked out great for me, but there's (obviously) a huge market for OOP.  I'm confused on how to apply the OOP concepts to what I'm already doing procedurally (or if OOP even applies to what I'm doing).  A lot of what I do is PHP/MySQL, so how do I apply OOP concepts to that relationship?  At what point do things become objects that should be put into a class?

     

    I found this example but it seems excessive compared to writing only a  simple connection function

    http://forum.ragezone.com/f427/simple-oophp-mysql-connection-679020/

  17. Hi all.

     

    I'm just getting my feet wet with OOPHP.  My question is "why have a setter method when you can just use the __construct method to set everything?" and "would you need a separate setter method for each attribute of an object?"(i.e. set_first, set_last, set_gender, etc.)

     

    The code...

    <?php
    class person{
    	var $first;
    	var $last;
    	var $gender;
    
    	function __construct($first,$last,$gender){
    		$this->first=$first;
    		$this->last=$last;
    		$this->gender=$gender;
    	}
    	function set_first($new_name){
    		$this->first=$new_name;
    	}
    	function get_person(){
    		return $this->first . $this->last . $this->gender;
    	}
    }
    ?>
    

  18. Solved it this way...

    if($result=="") return;

     

    I'm not meaning to be rude, but I could have goolged it myself and probably found the same thing.  I didn't because I have specific code with a specific problem.  That's why I prefer the forums over google searching.  In most cases, I can get a direct answer for a specific problem instead of something generic.

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.