Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Detecting DataList Type


Go to End


3 Posts   2001 Views

Avatar
codepattern

Community Member, 11 Posts

5 May 2014 at 3:21pm

This is probably some thing fairly easy but I can't wrap my mind around it. I am trying to put some condition based on whether a datalist is a HasManyList ot ManyManyList. For example, my debug output has ...

-----
ManyManyList

ClassName =

Image

Created =

2014-01-22 00:39:28

..etc

How do I figure out if the list is a ManyManyList or a HasManyList such as

if(ManyManyList) ...

elseif (HasManyList) ...

Thanks in advance

Avatar
(deleted)

Community Member, 473 Posts

5 May 2014 at 4:05pm

if ($list instanceof ManyManyList) {

} else if($list instanceof HasManyList) {

}

Avatar
codepattern

Community Member, 11 Posts

10 August 2015 at 10:00pm

Thanks