Link Vault
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5
Back to this add-on's main page
View Other Add-ons From Masuga Design
Get the top five downloads, but display the entries they’re attached to?
Support Request
Mike Mella
|
Posted: 07 June 2016 03:52 PM |
|
|
|
I have a Downloads channel where I create entries containing these fields:
- Title
- Description
- File
I’m using Link Vault to track downloads of the File field.
I want to display a “Top 5 most downloaded files” section on my homepage, but I don’t want to list the filenames themselves, I want to display field content from the channel entries that they’re uploaded to, like this:
1. <a href="{file-download-link}">{title}</a> {description} 2. <a href="{file-download-link}">{title}</a> {description} 3. <a href="{file-download-link}">{title}</a> {description} etc.
I guess I need to wrap the :records tag in a Channel Entries tag somehow?
|
|
|
Ben Kohl
|
Posted: 08 June 2016 09:46 AM |
# 1
|
|
|
Actually, it would be the other way around. You’d loop through the rows with the :records tag then use the entry_id column (as long as it is populated) to fetch the related entry data using a channel entries tag or the query module. I’d probably go with the query module since it is a small number of columns.
New download links could be generated from the data in the Link Vault download record so you wouldn’t even need the entry’s File field data from the entry query.
|
|
|
Mike Mella
|
Posted: 08 June 2016 12:27 PM |
# 2
|
|
|
Something like this?:
Download Link:
{exp:link_vault:download_link file_path='{cf-file}' text='{title}' entry_id='{entry_id}' }
Download Records:
{exp:link_vault:records table='downloads' group_by='file_name' order_by='census' sort='desc' limit='5' } {exp:channel:entries channel="documents" dynamic="no" entry_id="{entry_id}"} {title} was downloaded {census} times. <br><br> {/exp:channel:entries} {/exp:link_vault:records}
That doesn’t seem to work. The Entry ID is says “0” for every entry. Am I capturing it wrong?
|
|
|
Ben Kohl
|
Posted: 08 June 2016 12:40 PM |
# 3
|
|
|
If you check the entry_id column in the link_vault_downloads table, are all the values 0? If so, maybe the {entry_id} variable in the download link tag isn’t parsing correctly. If the :download_link tag is inside a channel entries loop, it should be parsing fine. Maybe another tag is overriding the {entry_id} variable?
|
|
|
Mike Mella
|
Posted: 08 June 2016 01:22 PM |
# 4
|
|
|
Okay I think I resolved that - I’m using Stash and I should have passed in a stashed value for the entry_id. Seems to work now.
But I’d like to have the documents in the records list clickable, so that you can download them right from there. Is it possible to nest a {exp:link_vault:download_link} tag inside the {exp:link_vault:records} tag?
|
|
|
Ben Kohl
|
Posted: 08 June 2016 01:27 PM |
# 5
|
|
|
Yes. You just might have to experiment with the parse=“inward” parameter depending on how your templates are set up.
|
|
|
Mike Mella
|
Posted: 09 June 2016 09:27 AM |
# 6
|
|
|
Thanks Ben. One more thing - Is there an easy way to clear out the download records? I’m testing the site and don’t want these entries counted when I launch.
|
|
|
Ben Kohl
|
Posted: 09 June 2016 09:36 AM |
# 7
|
|
|
The easiest way would be a SQL query. If you use Sequel Pro or another GUI, you could just delete the rows from there.
DELETE FROM exp_link_vault_downloads;
|
|
|