Jump to content

Recommended Posts

Posted

I'm creating a general function for batch import, for a site migration, and while looping through fields (field names) to be imported for a page, I need to check whether the field is an image (or other file type), so that it can be imported after the first pave save.

What would be the recommended way to check this, with PHP code?

Posted

Well, I managed to solve this now by just saving the page twice: Once before populating the page's fields, and once after.

Posted

That's one solution, the other would have been to determine the field type through the page's template.

$tpl = wire('templates')->get($templatename);
if( $tpl->fields->get($fieldname)->type instanceof FieldtypeFile ) { /* true for file and image field types, import as file */ }
  • Like 3

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
×
×
  • Create New...