Jump to:

23452 Posts in 18901 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » IF Silverstripe Version == 3 {} else { }

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 365 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    IF Silverstripe Version == 3 {} else { } Link to this post

    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?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: IF Silverstripe Version == 3 {} else { } Link to this post

    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.

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: IF Silverstripe Version == 3 {} else { } Link to this post

    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!

    365 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.