Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Is it possible to "manually" build a URL

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1528 Views
  • cevic
    Community Member
    5 Posts

    Is it possible to "manually" build a URL Link to this post

    I need to build a specifi site menu that doesn't allow me to use a loop:

    <div id="tres">
       <li id="nav-home"><a href="#">Home</a></li>
       <li id="nav-horario"><a id=href="#">Horario</a></li>
    <div id="cuatro">
       <li id="nav-ubicacion"><a href="#">Ubicacion</a></li>

    Is there a way I can manually build urls for my menu? What I mean is, is there any page controller I can use to generate a URL (something like $Pageurl(4) will give me the same output of $Link for a specific ID)

    [I just realised my question is the same as in http://www.silverstripe.com/site-builders-forum/flat/26072 which hasn't been answered yet]

  • newjamie
    Community Member
    7 Posts

    Re: Is it possible to "manually" build a URL Link to this post


    You can do this with a custom controller, for example in your .php file add this to the controller:

    function LinkFromID($id)

    $thisPage = DataObject::get_by_id("Page",$id);

    return $thisPage;

    And in your template, call the controller with the ID

    <% control LinkFromID(5) %>
    <% end_control %>

    would return the link for the page with ID 5.

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.