21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 860 Views |
-
Getting URL from Sitetree

29 April 2011 at 5:28am Last edited: 29 April 2011 5:31am
Hi,
I'm new to SS so I'd appreciate any assistance!
I have a SQL Query to retrieve some sitetree records from a dataobject (which is created by a DailyTask).
The query returns 10 sitetree dataobjects selected through a join with the Top Ten dataobject.
I loop through those in the template.ss and wish to provide a link in the href to each one.
I would like to know the most efficient way to retrieve the url link for those dataobjects as $Link does not work (it aint a field on the dataobjectset).
function GetTopTen ($country) {
$sqlQuery = new SQLQuery();
$sqlQuery->select = array('*');
$sqlQuery->from = array("TopTen",
"FULL JOIN SiteTree ON TopTenPageID = SiteTree.ID"
);
$sqlQuery->where = array("TopTenCountry = 'ie'");
$sqlQuery->limit = "10";
// execute and return a Query-object
$result = $sqlQuery->execute();
$dataObject1 = new DataObjectSet();foreach($result as $row) {
//move the SQL result data to the DataObjectSet
$dataObject1->push(new ArrayData($row));
}
return $dataObject1;My template layer loops through the returned dataobjectset and outputs the Page with a link to it.
<% control GetTopTen(ie) %>
<li><a href="<% GetLink($ID) %>">$Title</a></li>
<% end_control %>Thanks in advance!
Nick
-
Re: Getting URL from Sitetree

29 April 2011 at 10:19pm
Please Help! I still can't find an elegant solution to this one and I know there has to be something fairly straightforward to achieve this.....
-
Re: Getting URL from Sitetree

30 April 2011 at 1:34am
<% GetLink($ID) %>
You can't pass variables into functions (as is mentioned on the template pages) as of the 2.x series. You would do your link function inside the loop you already have in the PHP.
foreach($result as $row) {
// get the link
$row['Link'] = ... your function link($row ['ID']) ....//move the SQL result data to the DataObjectSet
$dataObject1->push(new ArrayData($row));
}Then you would simply use $Link in the template.
| 860 Views | ||
|
Page:
1
|
Go to Top |


