saml Posted November 21, 2015 Share Posted November 21, 2015 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? Link to comment Share on other sites More sharing options...
saml Posted November 22, 2015 Author Share Posted November 22, 2015 Well, I managed to solve this now by just saving the page twice: Once before populating the page's fields, and once after. Link to comment Share on other sites More sharing options...
BitPoet Posted November 22, 2015 Share Posted November 22, 2015 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 */ } 3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now