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.

Archive /

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

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

Is it possible to "manually" build a URL

Go to End

2 Posts   1883 Views


Community Member, 5 Posts

17 March 2008 at 1:52am

Edited: 17/03/2008 7:53am

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]


Community Member, 7 Posts

17 March 2008 at 10:56am


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.