php


SilverStripe sort page list by custom order


Is there a way to sort the list of pages in the create page menu by a custom order (instead of alphabetically ie).
I'm looking for a solution similar to the way ModelAdmin menu items are ordered:
private static $menu_priority = 2;
Currently not, cause it's hardcoded to sort by "Singular Name", see https://github.com/silverstripe/silverstripe-cms/blob/3.5/code/controllers/CMSMain.php#L493
Nevertheless you could subclass CMSMain class, overwrite the method PageTypes() and tell SilverStripe to use your subclass instead of the original with an Injector.
E.g.:
class CustomCMSMain extends CMSMain {
public function init() {
parent::init(); //set a breakpoint here to prove this class is called
}
public function PageTypes() {
//do something
}
}
and in your config.yml
Injector:
CMSMain:
class: CustomCMSMain
After a flush SilverStripe should use your own class which you can easily verify by setting a xdebug breakpoint in your own class, e.g. in the init method.
See docs for injector

Related Links

Alternative conditional syntax (if-else) failing on PHP 5.3.0 (xampp)
Bulk Insert Code Before </body> Tag in 100 Files
Scraping from wsj.com or finance.yahoo.com
what is wrong with this mysql code
How to unit-test an enterprise symfony project?
How to delete object from array inside foreach loop?
How to update Select menu with AJAX w/out <div> inside form
nesting conditions with DQL
On mac OS, I've enabled PHP but seem to have permission problems. How do I enable subdirectories?
Take a quick look at this for loop, what is wrong?
PHP: Tips on having different languages
are scenarios/stories the new interface in BDD/TDD?
Basic foreach loop question
small error I cant find, please check this rename() function
Problem with Symfony routing with online project
Placeholders using generic ODBC drivers

Categories

HOME
apple-push-notifications
dotnetnuke
schema.org
opencv-python
applescript
braintree
initialization
slider
qooxdoo
moodle-api
specifications
cisco
jpa-criteria
clickable-image
match
rangy
business-intelligence
smooks
angular4
google-cloud-logging
pickle
ava
eclipse-emf
function-points
jackrabbit-oak
bitbake
region
openbr
phpstorm-2016.1
mongodb-3.4
xcrun
plantuml
caesar-cipher
polyml
nppexec
netstat
fastlane
microsoft-ui-automation
llvm-ir
grails3.2.0
secure-coding
hypothesis-test
httphandler
permission-denied
apache-toree
reverse-dns
jenkins-slave
gcal
hibernate-ogm
amazon-elastic-beanstalk
visual-format-language
extjs4.1
sigsegv
watir-webdriver
portability
clrs
.when
mpmovieplayercontroller
emf-compare
rational-performance-test
metabase
thread-exceptions
okio
e
s-function
logical
adjacency-list
processor
lovefield
json-spirit
html.actionlink
fanotify
ora-04091
blank-line
mixins
jnlp
wicked-gem
shell-extensions
mod-auth-openidc
kognitio-wx2
createfile
global-scope
dmake
back
mobile-country-code
android-2.3-gingerbread
two.js
san
acceptance-testing
flv
eager-loading
2d-vector
session-0-isolation
jsplitpane
gprof
playorm
exponent
wiktionary
groovy-console
regression-testing
ninject-interception
odac
oracle-pro-c
rawcontacts
autobench

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App