我有一个网站,我希望能够从我目前所在的ProductPage
链接到下一个ProductPage
。我可以为即时兄弟姐妹做这件事,但是一旦我到达那个集合的末尾,我想链接到下一个ProductRange
第一个产品。结构是这样的:
ProductArea
ProductCategory
- ProductRange
- ProductPage
- ProductPage
- ProductRange
- ProductPage
- ProductPage
ProductCategory
- ProductRange
- ProductPage
- ProductPage
- ProductRange
- ProductPage
- ProductPage
因此,如果没有直接的兄弟姐妹,我需要按顺序返回下一个产品页面。
我正在使用这个直接兄弟姐妹:
function NextProduct() {
$pages = ProductPage::get()->filter(array(
'ParentID' => $this->ParentID,
'Sort:GreaterThan' => $this->Sort
))->Sort('Sort');
if ($pages) {
return $pages->First();
}
}
如何让它在下一级工作?
答案 0 :(得分:1)
这是一种方法。首先,我们试图找到下一个兄弟姐妹。如果下一个兄弟姐妹不存在,我们将获得下一个父页面并获得他们的第一个孩子。
Dim db As Database
Set db = CurrentDb
Dim rs As ADODB.Recordset
Dim msQry(0) As String
Dim accessQry(0) As String
Dim msSqlAccessRelations As New Hashtable
msQry(0) = "Select * From [IFSDB].[dbo].[Notes] Where ReferNum = " & ReferNum & " AND ReferTypeId = " & ReferTypeId & " " & extraFilter & " Order by NoteID desc"
accessQry(0) = "Select CurrentUserId , CurrentUserPrinted from TblCurrentUser"
msSqlAccessRelations.Add "CurrentUserId", "CurrentUserId"
If GetMSSQLDown = False Then
Set GetNotes = GetDataToDifferentDb(msQry, accessQry, msSqlAccessRelations, "CurrentUserPrinted,Note,NoteID,CurrentUserId,ReferNum,ReferTypeId,AppearOnReport,AppearOnBOLReport,Date,ShowForPickers")
Else
Set GetNotes = rs
End If
这是一个function NextProduct() {
$pages = ProductPage::get()->filter(array(
'ParentID' => $this->ParentID,
'Sort:GreaterThan' => $this->Sort
))->Sort('Sort')->limit(1);
if ($pages->count()) {
return $pages->First();
}
$parent = $this->parent();
$parentSiblings = ProductRange::get()->filter(array(
'ParentID' => $parent->ParentID,
'Sort:GreaterThan' => $parent->Sort
))->Sort('Sort');
foreach ($parentSiblings as $parentSibling) {
$pages = ProductPage::get()->filter(array(
'ParentID' => $parentSibling->ID
))->Sort('Sort')->limit(1);
if ($pages->count()) {
return $pages->First();
}
}
return false;
}
函数:
PreviousProduct