Ok, So Ive been developing websites for a long time now and Im halfway through writing my own cms.
But ive been having a real issue with auto generating my navigation menus.
Basically the Menu Structure is in a plain text file:
Code:
index=Home
hello=Hello
goodbye=Exit
-other=Sign Out
-other2=Sign Out2
-other3=Sign Out3
girls=Girls
-ali=Ali
-emma=Emma
testingfile=TEST
boys=Boys
-johns=Johns
--johnjames=John James
--johnmaycock=John Maycock
-jamie=Jamie
Id like to automatically get that into this format:
Code:
<ul>
<li><a href='index'>Home</a></li>
<li><a href='hello'>Hello</a></li>
<li><a href='goodbye'>Exit</a>
<ul>
<li><a href='other'>Sign Out</a></li>
<li><a href='other2'>Sign Out2</a></li>
<li><a href='other3'>Sign Out3</a></li>
</ul>
</li>
<li><a href='girls'>Girls</a>
<ul>
<li><a href='ali'>Ali</a></li>
<li><a href='emma'>Emma</a></li>
</ul>
<li><a href='testingfile'>TEST</a></li>
<li><a href='boys'>Boys</a>
<ul>
<li><a href='johns'>Johns</a>
<ul>
<li><a href='johnjames'>John James</a></li>
<li><a href='johnmaycock'>John Maycock</a></li>
</ul>
</li>
<li><a href='jamie'>Jamie</a><li>
</ul>
</li>
</ul>
Im not looking for a full solution, Im a proficiant coder, but i just cant work out the logic behind it.
Basically Im splitting each line into an 2-dimensional array:
so we have:
$arr['id'] = 'index';
$arr['name'] = 'Home';
or
$arr['id'] = '--johnmaycock';
$arr['name'] = 'John Maycock';
Then I was trying to read the first couple of characters to work out if it was a sub, or sub-sub menu.. but.... I cant get my head around it.
I got it working with just sub menus, but couldn't get sub-sub to work.
Im more than welcome to completely different suggestions!