17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1418 Views |
-
Is it possible to "manually" build a URL

17 March 2008 at 1:52am Last edited: 17 March 2008 7:53am
I need to build a specifi site menu that doesn't allow me to use a loop:
<div id="tres">
<ul>
<li id="nav-home"><a href="#">Home</a></li>
<li id="nav-horario"><a id=href="#">Horario</a></li>
</ul>
</div>
<div id="cuatro">
<ul>
<li id="nav-ubicacion"><a href="#">Ubicacion</a></li>
</ul>
</div>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]
-
Re: Is it possible to "manually" build a URL

17 March 2008 at 10:56am
Sure
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) %>
$Link
<% end_control %>would return the link for the page with ID 5.
| 1418 Views | ||
|
Page:
1
|
Go to Top |


