Implementing elgg_file_viewer extension

I want to use the elgg_file_viewer extension to render the contents of files inline, but I don't see any functions, classes or methods that I should use.  I would expect to implement it using something like, "echo elgg_render_file($entity,['option'=>'value']);" or "$entity->renderFile();", but I don't see such things.

How does one implement the elgg_file_viewer extension?  I'm guessing it's super simple.  Sometimes those are the hardest things to see.

Thank you,

 - Scott

  • OK.  I figured out that, as an extension to the File plugin, one must use the file plugin to render the file thusly: elgg_view_entity($file);  Having figured that out, I get an "Error 400 (Bad Request)!!1" error for nearly every file I try to render.  *.jpeg works, but nothing else does.  Not all error out, but nothing else renders.

    Is there a remedy for this issue?  I realize the file_viewer extension is no longer active, but I'm hoping *you* may have addressed and solved this.

    Thank you,

     - Scott

  • Update:  I'm still on 2.3.16.  The issue stems from the function elgg_get_download_url($file) not returning a value.  I understand that the function only works on a standard filestore.

    How does one determine whether the filestore is 'standard' or custom?  I have not used the setFilestore method anywhere, so I think it's safe to presume that it it a standard filestore.

    Also, is there a known issue with elgg_get_download_url() on 2.3?  If not, do you have suggestions for what to try next?

  • Do you use the File Viewer plugin at https://elgg.org/plugins/2648090? It should work on Elgg 2.3. It supports a number of file types already. For other file types I think you need to provide a view in views/default/file/specialcontent where the exact location within depends on the mimetype of the file. The view would deal with displaying the file. For some content you probably need to make use of additional libraries and other other code elsewhere to the plugin. But that would be a task for you to study all code of the plugin to understand how the different parts work together and how to add additional functionality.

  • Yes, I am using the File Viewer plugin at https://elgg.org/plugins/2648090, but it's not showing the content because it sends the download URL to the render engine using the function elgg_get_download_url($file).  This function is not returning a value.

  • I resolved the issue.  In my version upgrades, the 'filestore::dir_root' metastring string value did not get updated to the new filestore location.  Bullocks!

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking