Jump to content

Find all fields that are multi language


gebeer
 Share

Recommended Posts

Hello,

I would like to find all fields that are multi-language.

My code

$langFields = new FieldsArray;
foreach ($fields as $f) {
	if($f->type instanceof FieldtypePageTitleLanguage || $f->type instanceof FieldtypeTextareaLanguage || $f->type instanceof FieldtypeTextLanguage) {
		$langFields->add($f);
	}
}

Is there a more generic way of how I can determine whether a field is multi language, other than checking  "$f->type instanceof" for all three fieldtypes?

Link to comment
Share on other sites

Untested, but every multi language field class should implement FieldtypeLanguageInterface, which you should be able to check for using instanceof.

if($f->type instanceof FieldtypeLanguageInterface) $langFields->add($f);
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...