where is the description in the file field? [explaned]

More
10 years 1 month ago #46208 by dmayak
Hello, can you tell how to get a description, title or filename separately inside the template? FlexicontentFields::getFieldDisplay gives already composed html string, but I need to display files list in a table-like structure so I need to get it separately.

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #46212 by ggppdk
Hello

no need to re-query DB (and waste CPU), the raw field values are already retrieved via a single SQL query and available in each item as:

$item->fieldvalues[ field_id ]

Please see our FAQ article:
Using the raw value of a field inside a template file


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #46219 by dmayak
Yes, but for the file type field it contains what seem to be file id's:
Code:
array(1) { [34]=> array(3) { [0]=> string(2) "86" [1]=> string(2) "31" [2]=> string(2) "80" } }
So my question is better rephrased as how to get file info by its id. There should be some method to access this data, except directly access _flexicontent_files table. Unfortunately have not found any info on this.

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #46229 by ggppdk
Hello

are creating the HTML of the file field ?

e.g have added field to a render-only position


if you do the above, then you can make a slight modification so that these data are available


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #46234 by dmayak

ggppdk wrote: Hello

are creating the HTML of the file field ?

e.g have added field to a render-only position


if you do the above, then you can make a slight modification so that these data are available

No, I am not using template positions in this template, it's a custom template which purpose is to output selected files for download with some information about it.
I have created a separate page type and file type field with multiple values, and just need to list files on page. I have tried to use FlexicontentFields::getFieldDisplay($this->item, 'field name'), but it only gives html output as single string and array of links.
Here is how I have made it for now:
Code:
<?php if(isset($this->item->fieldvalues[$this->item->fields['resource_field']->id])){ $files_id_list=''; $counter=0; $ar_total=count($this->item->fieldvalues[$this->item->fields['resource_field']->id]); foreach($this->item->fieldvalues[$this->item->fields['resource_field']->id] as $file_id){ $files_id_list.='\''.$file_id.'\''; if($counter !== $ar_total - 1){$files_id_list.=',';} $counter++; } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array('id','filename', 'altname', 'description', 'access', 'ext')); $query->from('#__flexicontent_files'); $query->where('id IN('.$files_id_list.')'); $query->order('id ASC'); $db->setQuery($query); $files_info = $db->loadObjectList(); foreach($files_info as $file){ $file->link='/'.$this->item->alias.'/download/'.$file->id.'/'.$this->item->id.'/'.$this->item->fields['resource_field']->id; } foreach($files_info as $file){ if($file->access==1){ ?> <div class="resource_field"> <img class="file_icon" src="<?php echo $templateDir; ?>/img/<?php echo $file->ext; ?>.png"/> [url=<?php echo $file->link?>" class="file_link]<?php echo $file->altname?>[/url] <p class="file_desc"><?php echo $file->description; ?></p> </div> <?php } }
I am receiving all information I need about files and display it in custom format. I just thinking about how can I improve it so I can receive that data by flexicontent methods, maybe there is some additional arguments to getFieldDisplay function?

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #46253 by ggppdk
Hello

ok just you are executin 1 query per item, this is very fast, because files table is small and you are query via IDs !!

but if you display more than 100 items in category it maybe better to create only 1 query for ALL items


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.466 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline