File tree 4 files changed +26
-11
lines changed
4 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ ContentController:
11
11
extensions :
12
12
- SectionContentControllerExtension
13
13
url_handlers :
14
- ' section/$ID ! ' : ' handleSection'
14
+ ' section/$SECTIONNAME!/$ACTION ! ' : ' handleSection'
15
15
Injector :
16
16
GridField :
17
17
class : RowExtraClassesGridField
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ public function __contruct($section = null)
16
16
$ this ->section = $ section ;
17
17
$ this ->failover = $ section ;
18
18
}
19
-
19
+ $ this ->CurrentPage = Controller::curr ();
20
+ Debug::dump ($ section );
20
21
parent ::__contruct ();
21
22
}
22
23
@@ -39,13 +40,15 @@ public function Link($action = null)
39
40
}
40
41
return Controller::curr ()->Link ($ segment );
41
42
}
43
+
42
44
/**
43
- * @return string - link to page this section is on
45
+ * Access current page scope from section templates with $CurrentPage
46
+ *
47
+ * @return Controller
44
48
*/
45
- public function pageLink ()
49
+ public function getCurrentPage ()
46
50
{
47
- $ parts = explode ('/section/ ' , $ this ->Link ());
48
- return isset ($ parts [0 ]) ? $ parts [0 ] : null ;
51
+ return Controller::curr ();
49
52
}
50
53
51
54
public function getSection ()
Original file line number Diff line number Diff line change @@ -10,15 +10,18 @@ class SectionContentControllerExtension extends Extension {
10
10
11
11
/**
12
12
* Handles section attached to a page
13
- * Assumes URLs in the following format: <URLSegment>/section/<section-ID >.
13
+ * Assumes URLs in the following format: <URLSegment>/section/<section-id >.
14
14
*
15
15
* @return RequestHandler
16
16
*/
17
17
public function handleSection () {
18
- if ($ id = $ this ->owner ->getRequest ()->param ('ID ' )) {
18
+
19
+ if ($ ClassName = $ this ->owner ->getRequest ()->param ('SECTIONNAME ' )) {
19
20
$ sections = $ this ->owner ->data ()->Sections ();
20
- if ($ section = $ sections ->find ('ID ' , $ id )) {
21
- return $ section ->getController ();
21
+ if ($ section = $ sections ->filter (array ('ClassName ' => $ ClassName ))->first ()) {
22
+ if ($ action = $ this ->owner ->getRequest ()->param ('ACTION ' )) {
23
+ return $ section ->getController ()->$ action ();
24
+ }
22
25
}
23
26
}
24
27
// return $section->getController();
Original file line number Diff line number Diff line change @@ -286,12 +286,21 @@ public function Render(){
286
286
);
287
287
}
288
288
289
+ /**
290
+ * Access current page scope from section templates with $CurrentPage
291
+ *
292
+ * @return Controller
293
+ */
294
+ public function getCurrentPage ()
295
+ {
296
+ return Controller::curr ();
297
+ }
298
+
289
299
public function Layout ()
290
300
{
291
301
$ member = Member::currentUser ();
292
302
$ access = Permission::checkMember ($ member , 'CMS_ACCESS ' );
293
303
if ($ this ->Public || $ access ){
294
- $ this ->CurrentPage = Controller::curr ();
295
304
return $ this ->renderWith ($ this ->Render ());
296
305
}
297
306
}
You can’t perform that action at this time.
0 commit comments