I’m looking for some pointers regarding making an extension (in specific; Mark Huot’s File Extension but I’ve made use of a few of Mark’s extensions that will also require updating) Multi-site-manager compatible.
I’ve done a lot of searching but found very little on the topic. Might I also add that I am very new to EE, currently carrying out my first build.
Basically what I have is four sites, each with an “event” weblog and “Event-image” custom field (mh_file_ext) respectively.
What I need to be able to do is pull “events” from each site.
if(!isset($SESS->cache)) $SESS->cache = array(); if(!isset($SESS->cache['mh_file_ext_fields_'.$site_id])) { $SESS->cache['mh_file_ext_fields_'.$site_id] = $DB->query('SELECT * FROM exp_weblog_fields f, exp_upload_prefs p WHERE f.field_type="file" AND p.id=f.field_list_items AND f.site_id='.$site_id); }
// ============================================= // Loop Through Fields // ============================================= foreach($SESS->cache['mh_file_ext_fields_'.$site_id]->result as $file_field) { // ============================================= // Does the field exist? // ============================================= if(!isset($row['field_id_'.$file_field['field_id']])) { $tagdata = $this->clean_tagdata($tagdata, $file_field['field_name']); continue; }
// ============================================= // Are there files? // ============================================= if(trim($row['field_id_'.$file_field['field_id']]) == '') { $tagdata = $this->clean_tagdata($tagdata, $file_field['field_name']); continue; }
// ============================================= // Split out to array // ============================================= // We'll also want to clear our empty rows and // reset our indexes to 0, that's what the three // calls do. // --------------------------------------------- $files = array(); $thumbs = array(); $all_files = array_merge(array_filter(preg_split('/\s*[\r\n]+\s*/', $row['field_id_'.$file_field['field_id']]))); foreach($all_files as $file) { if(preg_match('/'.$this->thumb_suffix.'\.[^.]*$/', $file)) { $thumbs[] = $file; } else { $files[] = $file; } }
// ============================================= // Are there still files or thumbs? // ============================================= if(count($files) === 0 && count($thumbs) === 0) { $tagdata = $this->clean_tagdata($tagdata, $file_field['field_name']); continue; }
// ============================================= // Reset then Get Settings // ============================================= $this->_set_prefs($file_field['field_list_items']);
// ============================================= // Store Field Name // ============================================= // This will make later stuff much shorter. // --------------------------------------------- $field_name = $file_field['field_name'];
if(!isset($SESS->cache)) $SESS->cache = array(); if(!isset($SESS->cache['mh_file_ext_fields'])) { $SESS->cache['mh_file_ext_fields'] = $DB->query('SELECT * FROM exp_weblog_fields f, exp_upload_prefs p WHERE f.field_type="file" AND p.id=f.field_list_items AND (f.site_id=1 OR f.site_id=14)');
}
// ============================================= // Loop Through Fields // ============================================= foreach($SESS->cache['mh_file_ext_fields']->result as $file_field) { // ============================================= // Does the field exist? // ============================================= if(!isset($row['field_id_'.$file_field['field_id']])) { $tagdata = $this->clean_tagdata($tagdata, $file_field['field_name']); continue; }
// ============================================= // Are there files? // ============================================= if(trim($row['field_id_'.$file_field['field_id']]) == '') { $tagdata = $this->clean_tagdata($tagdata, $file_field['field_name']); continue; }
// ============================================= // Split out to array // ============================================= // We'll also want to clear our empty rows and // reset our indexes to 0, that's what the three // calls do. // --------------------------------------------- $files = array(); $thumbs = array(); $all_files = array_merge(array_filter(preg_split('/\s*[\r\n]+\s*/', $row['field_id_'.$file_field['field_id']]))); foreach($all_files as $file) { if(preg_match('/'.$this->thumb_suffix.'\.[^.]*$/', $file)) { $thumbs[] = $file; } else { $files[] = $file; } }
// ============================================= // Are there still files or thumbs? // ============================================= if(count($files) === 0 && count($thumbs) === 0) { $tagdata = $this->clean_tagdata($tagdata, $file_field['field_name']); continue; }
// ============================================= // Reset then Get Settings // ============================================= $this->_set_prefs($file_field['field_list_items']);
// ============================================= // Store Field Name // ============================================= // This will make later stuff much shorter. // --------------------------------------------- $field_name = $file_field['field_name'];
$SESS->cache['mh_file_ext_fields'] = $DB->query('SELECT * FROM exp_weblog_fields f, exp_upload_prefs p WHERE f.field_type="file" AND p.id=f.field_list_items AND (f.site_id=1 OR f.site_id=14)');
But, both only populate the template with one of the “sites” file custom field data.
If any one could shed a little light on the situation I’d be greatly appreciate it. I’m literally banging my head against a brick wall (with an impending deadline looming overhead!).
Thanks in advance.
Matt @ View
p.s. can any one advise a better way to provide code examples (other than splitting posts). I tried to attach .php files but got denied. I then renamed .php to .txt and got told I had invalid content for the MIME type (text?).
FYI I’ve now had to abandon using Mark Huots file extension. I’ve wasted too much time already. Hopefully if I get a chance to revisit it in the future once my understanding of the EE framework is better.
If any one could point me in the direction of an EE extension HOWTO/tutorial I’d be most greatful. There is very little information available online.