gwcoleman

Send private message

You must be logged in to send a private message.

Friends

No friends yet.

Group membership

Activity

  • gwcoleman replied on the discussion topic Elgg returning ElggObject instead of ElggFiles
    Thanks for your response. I tested out the functionality you suggested and Elgg is still returning a ElggObject instead of a ElggFile.... :/   This throws an error: Argument 1 passed to elgg_get_download_url() must be an instance of... view reply
  • gwcoleman added a new discussion topic Elgg returning ElggObject instead of ElggFiles in the group Elgg Technical Support
    Hi, I'm new to working with Elgg. For my workplace I am attempting to create a system that can upload motion capture data and output the animation inside a custom widget. I am having difficulty retrieving the data once I upload it....
    • Thanks for your response. I tested out the functionality you suggested and Elgg is still returning a ElggObject instead of a ElggFile.... :/

       

      This throws an error:

      Argument 1 passed to elgg_get_download_url() must be an instance of ElggFile, instance of ElggObject given

       

      code:

      $content = elgg_get_entities(array(
      'type' => 'object',
      'subtype' => 'motion_data',
          'owner_guid' => elgg_get_page_owner_entity(),
          
      'no_results' => elgg_echo("file:none"),
      'preload_owners' => true,
      'preload_containers' => true,
      'distinct' => false,
      ));
       
       
      foreach ($content as $t)
      {
       
      $File = get_entity($t->guid);
       
      //throws an error
      $url = elgg_get_download_url($File);
      //also throws an error
      $url = elgg_get_download_url($t);
      }
    • Yeah, I also had that issue.

      Here's the thing, if you are dealing with files, as far as I know, you cannot use another subtype because elgg will not recognized as a file.

      If you see at my code, in the elgg_get_entities() I am filtering my files with an specific category. So in my action, I keep the file subtype, but I add a category:

      $file = new ElggFile();

      $file->title = $file->getFilename();

      $file->subtype = "file";

      $file->category = "featured";

      Then when I want to get the files I need, I just add the category:

      elgg_get_entities(array( 'type' => 'object', 'subtype' => 'file', 'category' => 'featured')

      You can view how I do my action here:

      https://github.com/rjcalifornia/elggpress/blob/master/actions/posts/save.php

    • @gwcoleman Extend ElggFile using your own Class.

      Example:

      namespace MyPlugin;
      
      use ElggFile;
      
      class MotionData extends ElggFile {
      
          const SUBTYPE = 'motion_data';
      
          public function initializeAttributes() {
            parent::initializeAttributes();
            $this->attributes['subtype'] = self::SUBTYPE;
          }
      
      
         public function getDisplayName() {
            $name = parent::getDisplayName();
            
            if (!$name) {
              $name = elgg_echo('untitled');
           }
      
           return $name;
         }
      
      }