Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.


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

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

Is it possible to "manually" build a URL


2 Posts   1544 Views


17 March 2008 at 1:52am (Last edited: 17 March 2008 7:53am), Community Member, 5 Posts

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 which hasn't been answered yet]


17 March 2008 at 10:56am Community Member, 7 Posts


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.