[4.x]
OK today's problem driving me mad:
It is simple really I want to access a field value.
The following sql and code has been lifted from /blogs/inc/widgets/widgets/_coll_media_index.widget.php and altered slightly to do the task in hand.
$SQL = new SQL();
if ($this->disp_params['album_sequence']) {
$SQL->SELECT('cat_name, post_ID, post_datestart, post_datemodified, post_main_cat_ID, post_urltitle, post_canonical_slug_ID,
post_tiny_slug_ID, post_ptyp_ID, post_title, post_excerpt, post_url,
file_ID, file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc');
} else {
$SQL->SELECT('post_ID, post_datestart, post_datemodified, post_main_cat_ID, post_urltitle, post_canonical_slug_ID,
post_tiny_slug_ID, post_ptyp_ID, post_title, post_excerpt, post_url,
file_ID, file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc');
}
$SQL->FROM('T_categories INNER JOIN T_postcats ON cat_ID = postcat_cat_ID
INNER JOIN T_items__item ON postcat_post_ID = post_ID
INNER JOIN T_links ON post_ID = link_itm_ID
INNER JOIN T_files ON link_file_ID = file_ID');
$SQL->WHERE('cat_blog_ID IN ('.$list_blogs.')'); // fp> TODO: want to restrict on images :]
$SQL->WHERE_and('post_status = "published"'); // TODO: this is a dirty hack. More should be shown.
$SQL->WHERE_and('post_datestart <= \''.remove_seconds($localtimenow).'\'');
$SQL->GROUP_BY('link_ID');
$SQL->LIMIT($this->disp_params['limit']*4); // fp> TODO: because we have no way of getting images only, we get 4 times more data than requested and hope that 25% at least will be images :/
if ($this->disp_params['album_sequence']) {
$SQL->ORDER_BY('cat_name, post_ID '.$this->disp_params['order_dir'].', link_ID');
} else {
$SQL->ORDER_BY(gen_order_clause($this->disp_params['order_by'], $this->disp_params['order_dir'],
'post_', 'post_ID '.$this->disp_params['order_dir'].', link_ID'));
}
$FileCache = & get_FileCache();
$FileList = new DataObjectList2($FileCache);
$FileList->sql = $SQL->get();
$FileList->query(false, false, false, 'Media index widget');
// grid/list display starts here
$layout = $this->disp_params['thumb_layout'];
echo_i("<!-- -------------------------- A $layout of all photos -------------------------- -->");
$nb_cols = $this->disp_params['grid_nb_cols'];
$count = 0;
$album_showing = '';
# @var File
while($File = & $FileList->get_next()) {
no doubt experts here will be familiar with the rest.
The next line I need to test the value of 'cat_name' field bfore continuing processing. The obvious $File->cat_name does not work.
I have checked the sql on the database and get a results set as expected.
Thanks in advance
$File object will only have file-related properties from evo_files table.
Try this