![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm working on a database-driven website focusing on mammals. I put a sample page online at http://mammals.geozoo.org/car/index.php If you click "Page Index" in the top left corner, a menu will open featuring ten items (Introduction, Home, Diet, etc.). Each item is linked to a heading on that same page. If you close the Page Index and scroll down and click "Who are we?" then choose Felidae, you'll go to a page that's almost identical. Click Page Index in the top left corner, and you'll see the same ten topics linked to articles on that same page. Obviously, I can't write about ten topics for every species of mammal. Therefore, the section on Intelligence will be blank for many species, for example (maybe even humans!). That isn't a problem by itself; if there's no content stored in the database, it simply won't register on the page. The problem is that the Page Index will still include the word "Intelligence," linked to a non-existent anchor on that page. So I'd like to know if there's a way to create a menu that will only display topics that are actually on the page. If there's an article about the polar bear's diet, then the polar bear page wiill display a Page Index that's linked to that article. If there is NO article about the polar bear's diet, then I don't want the linked word "Diet" to even appear on the Page Index. Can you think of a good strategy for designing something like this? I'm using PHP, connected to a MySQL database. This is what the HTML for my Page Index looks like at present: div id="navpageindex" class="menuDivHeader" onclick="P7_swapClass(1,'mnpageindex','showIt','hi deIt','div');P7_swapClass( |
|
enuButMinus','menuButPlus','img')">Page Index <img src="/images/arrows/pointers/bur.gif" width="6" height="12"></div div id="mnpageindex" class="showIt" div class="divindexes"> • <a href="#intro">Introduction</a><br / • <a href="#home">Home (Range & Habitat)</a><br / • <a href="#desc">Appearance & Anatomy</a><br / • <a href="#senses">Senses</a><br / • <a href="#intel">Intelligence & Behavior</a><br / • <a href="#action"><?=$data_details['FamMamPlural'] ?> in Action</a><br / • <a href="#diet">Diet</a><br / • <a href="#family">Reproduction & Family Life</a><br / • <a href="#enemies">Enemies</a><br / • <a href="#people"><?=$data_details['FamMamPlural'] ?> & People</a><br / /div /div Thanks. |
#3
| |||
| |||
|
|
What I would do is simply wrap the control for the menu in a repeat region using the database recordset that will feed the main content. That way if an element is not in the main section it will not appear in the menu. |
#4
| |||
| |||
|
|
Paul Whitham TMM wrote: What I would do is simply wrap the control for the menu in a repeat region using the database recordset that will feed the main content. That way if an element is not in the main section it will not appear in the menu. Sorry to be so dense, but could you elaborate on that just a bit, or post an example? I started out using recordsets, then began hand coding most of my stuff so I could better understand how it all works. Now I'm getting rusty on using recordsets! Thanks. |
#5
| |||
| |||
|
|
David I do not know PHP so I can not give you a specific example however if your content is coming from a database then you are currently mapping it to the page. All you need to do is replace you current code for the menu with a repeat region that will pick up a key point from the returned records. |
![]() |
| Thread Tools | |
| Display Modes | |
| |