Flexi as downloads component?

More
9 years 11 months ago - 9 years 11 months ago #61706 by lipatovroman
Please help me with this:

I have file field and text field with name Hits.
I need each time user press on download button text field Hits value increases on 1



I think it should be sql query in file filed plugin.
But I 'm not programmer, so I can't understand how to make it.
Thanks.

P.S. I tried to edit file /plugins/flexicontent_fields/file/tmpl/value_InlineBoxes.php

After this code
Code:
// The download button in a mini form ... $actions_arr[] = '' .'<form id="form-download-'.$field->id.'-'.($n+1).'" method="post" action="'.$dl_link.'" style="display:inline-block;" >' .$file_data_fields .'<input type="submit" name="download-'.$field->id.'[]" class="'.$file_classes.' btn-success fcfile_downloadFile" title="'.$downloadsinfo.'" value="'.$downloadstext.'"/>' .'</form>'."\n";

I added own code:
Code:
if(isset($_POST['download-'.$field->id.'[]'])) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $sql= mysql_query ('UPDATE biblsoft_flexicontent_fields_item_relations SET value = value + 1 WHERE field_id = 22 and item_id = '.$item->id); }

But it does not work :(
Last edit: 9 years 11 months ago by lipatovroman.

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

More
9 years 11 months ago #61709 by micker
at first do no edit this field duplicate and rename value_YOURTEMPLATENAME.php and select it in field admin
you became safe for update

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
9 years 11 months ago #61712 by lipatovroman
Ok, I understand.
But can you help me with my problem?

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

More
9 years 11 months ago - 9 years 11 months ago #61720 by ggppdk
Hello

inside your template file
item.php (or item_html5.php)

you can use:
Code:
echo '<label class="label">'. JText::_('FLEXI_HITS').'</label>'; $file_data_arr = $item->fields['myfile_fieldname']->file_data; if ( empty($file_data_arr) ) echo 'no file exists'; else { $file_data = reset($file_data_arr); // get data of first file; echo $file_data->hits; }


-- 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 review. Thanks!
Last edit: 9 years 11 months ago by ggppdk.

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

More
9 years 11 months ago #61722 by lipatovroman
It seems you didn't understand me...
I need to get sum of all files downloads for item.

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

More
9 years 11 months ago - 9 years 11 months ago #61724 by ggppdk
Hello

a small loop can add them ...
Code:
echo '<label class="label">'. JText::_('FLEXI_HITS').'</label>'; $file_data_arr = $item->fields['myfile_fieldname']->file_data; $total_downloads = 0; foreach ($file_data_arr as $file_data) { $total_downloads += $file_data->hits; } echo $total_downloads;


-- 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 review. Thanks!
Last edit: 9 years 11 months ago by ggppdk.

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

More
9 years 11 months ago - 9 years 11 months ago #61727 by lipatovroman
Yes, it works perfect. I'm very very glad, that you understand me :cheer:
But, in this case I can't sort (order) items by this parameter (sum of downloads).

You wrote about this. About text field with downlooads sum.



So, I tried to make code which sends +1 to this field each time user press download button. But it does not work...
Last edit: 9 years 11 months ago by ggppdk.

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

More
9 years 11 months ago #61882 by ggppdk
Hello

so what do you suggest ?

adding a new ordering option for the items listing (=category view) ?

that
- will join with the files table calculate a sum of download for every item
- and then order items by it ?


-- 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 review. Thanks!

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

More
9 years 11 months ago - 9 years 11 months ago #61890 by lipatovroman

that
- will join with the files table calculate a sum of download for every item
- and then order items by it ?


It will be great, but I have no right to ask you about this.

Right now I ask for help me to make code, that adds +1 to text extra field.

Explain.

I have created 2 fields



Now I need to inscrease text field "Total downloads" on +1 each time user download any file from File filed.




I tried to write code for this , but I'm not programmer and it does not work..

P.S. There are many downloads components, but I want to create site on FC.
The main requirements to the site - the ability to sort items by ratings, hits and number of downloads.

Problem only in number of downloads, but we can solve this using text extra field that increases after downloading files.
Last edit: 9 years 11 months ago by lipatovroman.

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

More
9 years 11 months ago #61892 by ggppdk
Hello

(i think) no DB schema changes would be needed for this
- propably it is only needs join with the "flexicontent_files" an SQL aggregation (1 more case in the ordering clause)

it seems to be similar to the "Most rated" order and with similar performance cost ...

(please note that biggest cost of category view SQL is the ORDER clause, so adding a new ordering is not to be taken lightly)
e.g. i estimate that this can add 0.5 seconds if the current category view has 10,000 content items to our optimized SQL query for category view items

if it is like i suspect in both terms of little work to add and with similar performance as "Most rated",
- then will add 1 more ordering option "Most downloaded" in v3.0.15

github.com/FLEXIcontent/flexicontent-cck/issues/538


-- 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 review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
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
Save