Thanks for your sugestion Fabian,
Im looking for a more standard ways so that each "tier" is seperated
by a "/" to give the idea of folder depth
Anyone have any ideas?
Basically a tree-like structure.
On 31/03/2007, at 10:07 PM, Fabian Lange wrote:
>
> Hi Craig,
> I have had the same problem for my forum like application.
>
> I am using the sfNestedSetPlugin to store the tree.
> Besides the title column I store a routing_rule column with it.
> That gets calculated like this:
>
> const SEPARATOR ="-";
>
> public function getRoutableTitle() {
> $v=utf8_decode($this->getTitle());
> $skipChars = array("&", "/", "-");
> $v = str_replace($skipChars, "", $v);
> $v = str_replace(array("Ö","ö","Ä","ä","Ü","ü","ß"),
> array("Oe","oe","Ae","ae","Ue","ue","ss"),$v);
> $v = preg_replace("/\s+/i","_",$v);
> return $v;
> }
> public function rebuildRoutingRule() {
> $routingRule='';
> if($this->hasParent()) $routingRule.=
> $this->retrieveParent()->getRoutingRule();
> if($routingRule) $routingRule.=self::SEPARATOR;
> $routingRule.=$this->getRoutableTitle();
> $this->setRoutingRule($routingRule);
> }
>
> The first method converts the title in something that is good for a
> URL, the
> browser would be able to hand over spaces and umlauts but I dont
> like the
> look of the url after the page has loaded so I prevent this. As I
> know the
> characters appearing in the title this is okay, would perhaps need
> some more
> tricks when it would be completely open.
>
> So in your case the "routing rule" would look like this:
> Clients-Client1-Project1
>
> Now you can use this for your urls
> /section/Clients-Client1-Project1
>
> Which you can easily get and then internally use again to look up
> the real
> id of the section by just querying the routing_rule column
>
> .: Fabian
>
> -----Original Message-----
> From:
> [EMAIL PROTECTED]
> oups.c
> om
> [mailto:grbounce-3gx0ZwUAAACbeXgKRGBnB9JmBRJWwY06=fabian.lange=web.de@
> google
> groups.com] On Behalf Of Craig Boxall
> Sent: Samstag, 31. März 2007 04:26
> To: [email protected]
> Subject: [symfony-users] Routing Question
>
>
> Hi,
>
> Im creating a simple content management system where you can assign
> an item of content having a parent. This is to simulate a tree-like
> content structure
>
> So for example I want this kind of thing to work:
>
> - Home
> - Clients
> - Client1
> - Project1
> - Project2
> - Project3
> -Client2
> - Project1
> - About Us
>
> etc etc
>
> Now, I have a module called content with an action called show so to
> get an Item to show i would use at the moment.
>
> /content/show?title=Project1
>
> Using a routing rule, I now display that as just
>
> /Project1
>
> But what I really want is:
>
> /Clients/Client1/Project1
>
> How do I achieve this? In the database, I am storing the id of the
> parent so for example, the id for Clients is 2, the id for Client 1
> is 7 and the id for Project 1 is 8
>
> Maybe do some kind of recursive call? I dunno... ANy help is
> appreciated
>
> Cheers
> Craig
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---