Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix integration? #2

Open
tyssen opened this issue Jun 9, 2011 · 7 comments
Open

Matrix integration? #2

tyssen opened this issue Jun 9, 2011 · 7 comments

Comments

@tyssen
Copy link

tyssen commented Jun 9, 2011

Another feature that would be cool is if the fieldtype could work with Matrix too.

@vmichnowicz
Copy link
Owner

All my EE projects so far have not required Matrix so I have yet to acquire a license. But if I ever get around to buying a copy I'll definitely take this into consideration.

@tyssen
Copy link
Author

tyssen commented Jun 13, 2011

I've had a go at doing this myself but I've only got limited PHP skills and am running into an error: Unable to locate the model you have specified: vwm_secure_files_m. What's the best way to let you see the changes I've made?

@vmichnowicz
Copy link
Owner

The best way would be to fork the project and push your changes to your repository.

If you just have code from one or two files, you can create a gist

@tyssen
Copy link
Author

tyssen commented Jun 13, 2011

I went for the second option as I only made a couple of minor mods to the fieldtype: https://gist.github.com/f6defbe5ee5a50b81805

@vmichnowicz
Copy link
Owner

Humm, I'm not really sure why it would be giving that error. You could try loading the model like so:

$this->EE->load->model('models/vwm_secure_files_m');

I kinda doubt that will do anything though. Also your _files_select method should be private. All the other methods should be public. And I don't believe there is any need to pass the field_name and field_id to your _files_select method.

The EE model loader is located in system/codeigniter/system/core/Loader.php. You code poke around in the model method to see what it is trying to load unsuccessfully.

Does the code work outside of Matrix?

@tyssen
Copy link
Author

tyssen commented Jun 14, 2011

Yeah, changing $this->EE->load->model('vwm_secure_files_m'); to $this->EE->load->model('models/vwm_secure_files_m'); didn't do anything. So I tried hard-coding the path to the model into the file which let me save the field without producing the missing model error. But when going to the publish page, I now get this error:

Message: Undefined property: Content_publish::$vwm_secure_files_m
Filename: vwm_secure_files/ft.vwm_secure_files.php
Line Number: 73

Fatal error: Call to a member function all_files() on a non-object in ft.vwm_secure_files.php on line 73

I've updated the Gist with the latest code. And yes, what I had before was working OK for fields created outside Matrix.

@vmichnowicz
Copy link
Owner

There really should be a way to do this without require_once.

Maybe placing this in the constructor will work?

$this->EE =& get_instance();

If you have any EE addons that have fieldtype components that need to access a database table you could look at their code to see what they are doing. I have been looking around, but have yet to come across any that use models. Most just put the SQL right in the fieldtype...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants