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.

Data Model Questions /

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

access a outside $Link from within the control

Go to End

3 Posts   1841 Views


Community Member, 80 Posts

10 December 2009 at 8:19pm

Edited: 10/12/2009 8:20pm

I have three page type, 'MainPage' has 5 'PageHolder', each 'PageHolder' has number of 'QuestionPage'
on the I need to access $link of current child 'PageHolder' $Link, inside the custom control of 'firstQuestion'

<% if Children %>
<% control Children %>

<% if firstQuestion %>
<% control firstQuestion %>

<h4>"$Question"</h4> <br>
$Enquirer <br><br>

Previous Questions:

//I need to access this link
<a href="$Children.Link">View All</a>

<% end_control %>

<% if secondAndThirdQuestion %>
<% control secondAndThirdQuestion %>
<a href="$Link">$Question</a> <br>

<% end_control %>
<% end_if %>
<% end_if %>

<% end_control %>
<% end_if %>

the firstQuestion is inside the 'PageHolder'
public function firstQuestion(){
return DataObject::get("QuestionPage", "ParentID={$this->ID}", '', '', '0, 1');

I am trying to add another function
public function currentPageHolder(){
return $this->Link();


Could someone please shed some light on this. Thank you.


Community Member, 253 Posts

10 December 2009 at 10:51pm

Right, I don't think what you are trying to achieve is entirely clear.

Whatever it is, $Children.Link won't work as Children is a DataObjectSet, so it won't have a link associated.

If you want the link of the current Child you are 'controlling' then it is $Link.

If you want the Link of the page you are currently on (ie: The holder page) then you would use $Top.Link - but this will only show the link to the current page. So I'm not sure that is really what you want.

Anyway, there is no need for a custom method (currentPageHolder).

Hope that helps


Community Member, 80 Posts

11 December 2009 at 11:51am

Thanks for the reply. I can't use $Link, because it will return the firstQuestion page Link, I can't use $top.Link, because not only it break out the firstQuestion control, it also break out the Children control, and return the MainPage Link. I have tried them both before, it won't work. What I am after is the Children's Link.

I have managed to get it by using $Parent.Link, you are right, I don't need to write a custom function. Cheers.