#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Forreach not working in joomla 2.5


    Hello,

    i have below code which works perfectly to show | (a gap) in menu items in J1.5 but in J2.5, its not the gap

    for eg the menu item when using J1.5 showing Home | Articles | Events
    But using in J2.5 its showing Home Articles Events

    Below is the code, any suggestions
    Code:
    If($rows){
    $lt=1;
    foreach($rows as $row){
    $list.='<li><a href="'.mosGetLinkTop($row).'">'.$row->name.'</a>';
    $list.=' |</li> ';
    //$lt=$lt+1;
    }
    }
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1045
    Hi,

    are you sure that's the actual, untouched code generating the links? Because I cannot really think of a reason why the second line should not be executed.

    The commented out line makes my suspicious. Are you sure there isn't an if statement somewhere making sure the first element isn't prepended by a "|"? Are you sure you haven't broken it by removing the increment?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0
    Originally Posted by Jacques1
    Hi,

    are you sure that's the actual, untouched code generating the links? Because I cannot really think of a reason why the second line should not be executed.

    The commented out line makes my suspicious. Are you sure there isn't an if statement somewhere making sure the first element isn't prepended by a "|"? Are you sure you haven't broken it by removing the increment?
    i am so sorry, thought it was redundant - hence removed - below is the complete code

    Code:
    if($rows){
    		$lt=1;
    		foreach($rows as $row){
    			
    		if($vid!="" and $row->id==28){
    			$list.=' <li><a  href="index.php?option=com_dealer">Dealer</a>';
    		}else{
    			$list.='<li><a href="'.mosGetLinkTop($row).'">'.$row->name.'</a>';
    		}
    		$list.=' |</li> ';
    		//$lt=$lt+1;
    		}
    	}
    echo  substr($list,0,-2);
    }

IMN logo majestic logo threadwatch logo seochat tools logo