load the file link

More
10 years 3 months ago #43605 by salmonella
hello every body
i used flexicontent with my website
and it is amazing !!

but i have a question ,
now i have a file field " for uploading books "

can i load the link of that field into other text field ?

i know that we can use relations to do so with other types of fields

but i don't know how to do it with the field field

when i used that {{fieldvalue##nn}}
and the result was a number that i don't know what it means ?

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

More
10 years 3 months ago #43624 by ggppdk
Replied by ggppdk on topic load the file link
Hello

As you can read in popup description and in this FAQ article:
How to use raw field values inside the value of other fields


-- You can use other fields values replacements for almost all fields

-- but the file field is an exception to the above rule,
because it uses a special DB table to store it's data, so an extra step to query that table would be required.


A simple/easy solution (if you are a developer) is to use a custom template and edit the template files:

(for category view)
category_items.php AND/OR category_items_html5.php

(for item view)
item.php AND/OR item_html5.php


And then(Using info from this FAQ article):
Using the raw value of a field inside a template file

Code:
$field_id = 444; // !! CHANGE this !! $db = JFactory::getDBO(); $user = JFactory::getUser(); $fvals = $item->fieldvalues[$field_id]; if (!empty($fvals)) { $query = 'SELECT * FROM #__flexicontent_files WHERE id IN ("' .implode($fvals, '", "') .'")'; $db->setQuery($query); $file_data = $db->loadObjectList('id'); echo "<pre>" . print_r($file_data, true); echo "</pre>"; }

The above will retrieve the file data for all files of of file field no 444 (change this), for the current item: $item

the last line:
echo "<pre>" . print_r($file_data, true); echo "</pre>";

will print the array with file information, so that you can see what is available, please correct the above code if i made some mistake

Regards


-- 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 3 months ago #43672 by salmonella
Replied by salmonella on topic load the file link
Thanks ,
i tried it and i shows all the file data
but i want the url of the file

i think if you can help me with displaying the filename

i can add the fullpath to it , to have the link to the file

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

More
10 years 3 months ago #43689 by ggppdk
Replied by ggppdk on topic load the file link

salmonella wrote: Thanks ,
i tried it and i shows all the file data


Exactly it shows all data, you are supposed to use what you need (the above will make it very easy for a developer)

(If you you are not a developer than please use the provided graphical configuration interface of FLEXIcontent:
template, and field configuration)



so remove the print statements
echo ...
print_r(..)

and you use what you need

e.g.
Code:
foreach($file_data AS $file_id => $d) { echo $d->url . "<br/>"; }

Regards


-- 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
2 years 7 months ago - 2 years 7 months ago #80726 by iamrobert
Replied by iamrobert on topic load the file link
I wanted this design:



My administrator set-up:



So we need to pull the Alt Value (Title) and the download value from the db. We can work out the field required in the code below with:
Code:
echo "<pre>" . print_r($file_data, true); echo "</pre>";



CODE in (item.php):
Code:
$download_id = 999; // !! CHANGE this to your field ID!! $db = JFactory::getDBO(); $user = JFactory::getUser(); $downvals = $item->fieldvalues[ $download_id ]; if ( !empty( $downvals ) ) {   $query = 'SELECT * FROM #__flexicontent_files WHERE id IN ("'     . implode( '", "', $downvals )     . '")';   $db->setQuery( $query );   $file_data = $db->loadObjectList( 'id' );   // echo "<pre>" . print_r($file_data, true); echo "</pre>";   foreach ( $file_data AS $file_id => $d ) {     $dl_link = 'index.php?option=com_flexicontent&id=' . $d->id . '&cid=' . $item->id . '&fid=' . $download_id . '&task=download';     $dl_link = flexicontent_html::getSefUrl( $dl_link ) . '?method=view';     echo '<div class="grid"> <div class="col"> <p>' . $d->altname . '</p> </div>   <div class="col">     <p><a href="' . $dl_link . '" target="_blank" class="button"><i class="icon icon-download"></i>Download</a></p>   </div> </div>';   } }


I found the $d->URL just gave the file ID value, not the full URL. So - used the $dl_link from the /plugins/flexicontent_fields/file/tmpl/value_InlineBoxes.php.

For php7.4 I needed to reverse the implode from implode($fvals, '", "')

to
Code:
implode( '", "', $
fvals
Code:
)

Hope someone finds it useful.


 
Last edit: 2 years 7 months ago by iamrobert.

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.302 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