21301 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 201 Views |
-
IF Silverstripe Version == 3 {} else { }

27 June 2012 at 12:01pm
Hi,
I'm making a shop module, I've been building for SS3, but a few servers I use won't run SS3, so i'm having to revert a few lines back to SS2.4 code. (eg, forms, datagrid)
I would like the module to work for both - the changes are quite small,
Is there a way of doing something like
IF ($SilverstripeVersion >= 3) {} else { }
so that I could make the code work for both system?
-
Re: IF Silverstripe Version == 3 {} else { }

27 June 2012 at 6:25pm
Not another shop module! Ha so many popping up now. The short answer to your version question is no (that I'm aware of). You can do LeftAndMain::CMSVersion() to return the version information but this may not always be set. A common pattern is to check for a class which has been added (i.e class_exists('DataList') ? "3.X" : "2.X");
3.0 does have quite a few major changes (more template functionality) and new ORM which would make your code potential much cleaner in 3.0 so depending on how complex it is, you may find it easier with 2 branches.
-
Re: IF Silverstripe Version == 3 {} else { }

27 June 2012 at 6:34pm
Hi Will
Yes - not-another-shop-module! I'm not releasing to the modules list, it's just something I use on a few website of my own for simple client shops, and I customise it to their needs.
At this stage there are only a couple of parts that need to be different for SS3, so I'll try and use your suggestions of checking if classes exist. As things move more to SS3 I'll take advantage of the extra stuff, but for now, i'm just trying to make things work with as little effort as possible!
| 201 Views | ||
|
Page:
1
|
Go to Top |


