Re: DB_NestedSet with HTML Menu - Can I use URL filename without ID?
| From: | Daniel Khan | Date: | Mon, 09 Jul 2007 19:17:05 +0000 |
| Subject: | Re: DB_NestedSet with HTML Menu - Can I use URL filename without ID? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27646@lists.php.net to get a copy of this message | ||
Hi Mark,
I am not sure if I got your point but I am doing my best :)
Mark Reynolds schrieb:
[..]
So if the $node['level'] is equal to 1 it displays the $node['name'] in the URL. eg. http://www.domain.com/root/ or if the $node['level'] is greater than 1 it displays the $node['name'] as the filename plus it's root name as the 'directory'. I want to keep the url down to this depth and not include subnodes etc. eg. http://www.domain.com/root/leaf.htm However I've been struggling with the detail/coding for this. So advice would be appreciated on this.Means if($level == 1) { this url } if($level == 1) { that url } So that shouldn't be a problem. You have to code this this way.
Once the links are displayed correctly there's the important issue of returning the $node[id'] based on the filename from the url, so that the ID can be given to the PickNode function. How can I carry the above out? Is it possible? Due to the lack of documentation I've looked through the relevent pear files but [..]I think what you are looking for is pickNode(): http://pear.php.net/package/DB_NestedSet/docs/latest/DB_NestedSet/DB_NestedSet.html#methodpickNode (there is no enduser docu - but the api doc is complete and verbose) <?php $searchNode = 'foo'; $mynode = $NeSe->pickNode($searchNode, true, true, 'name'); // if 'name' contains the nodename. ?> Another advice. You can create friendly urls using mod_rewrite and I really recommend to use the node id inside the url. As soon as you have 2 nodes with the same name your code won't work anymore. Look at - http://www.shopping.at/Baby_kind,564/Baby_und_Kind.html - http://www.fisherprice.at/fisher-price-roll-a-rounds-Kat762.html I've used DB_Nested in both and both have the id inside the url. The are still search engine friendly.. (http://www.google.at/search?q=site%3Awww.shopping.at) Hth - just ask if you need more help -- Daniel Khan