Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
hjmaier Posted April 14, 2017 Posted April 14, 2017 Dear all, I have a custom upload field in Pages, called anhang (it was a migration from IPS 3.4). I am struggling a bit to figure out the correct Display Custom Format. What I want to archive: 1. Have a separate line for each download 2. I want to see the correct file name and not the whole URL. I tried something like this according to a topic I found here: {{$anhang = $record->customFieldDisplayByKey('anhang', 'raw');}} {{foreach $anhang as $anhang_url}} <br/> <a href="{$anhang_url}">{$anhang_url}</a> {{endforeach}} But this of course shows me only the "real" url and not the attachment name: The url should look like something like this: http://www.midgard-forum.de/forum/applications/cms/interface/file/file.php?record=1593&database=1&file=monthly_04_2017%2F2016%252011%2520Midgard%2520Lernkosten%2520Zauberschutz%2520und%2520Zaubermittel%2520M5%2520v1.21.ods.413025493ee2e741b72bddabd2f4b0b1 Any idea how I can solve my problem?
opentype Posted April 14, 2017 Posted April 14, 2017 You can get the raw content of the field through $record->field_XXX, where XXX is the field ID. In a multi-upload field, the upload URLs are comma separated, so you can do $image_exploded = explode(',',$record->field_XXX) and then loop through it. Not really sure though why you do that i the template and not in the field settings and why you seem to want to construct the entries manually. That sounds rather cumbersome, but I am not sure what you are trying to achieve.
hjmaier Posted April 15, 2017 Author Posted April 15, 2017 @opentype Sorry, I meant the field options. I tried to put it here: But it did not give me the result I wanted. {$formValue} and {$value} give me something like this (only the text with no link):
opentype Posted April 15, 2017 Posted April 15, 2017 $record is for the template, not the field options. In the field options, do something like this: {{if $formValue}} {{$anhaenge = explode(',',$formValue);}} {{foreach $anhaenge as $anhang}} <p><a href="{file='$anhang' extension='cms_records'}">{$anhang}</a></p> {{endforeach}} {{endif}}
hjmaier Posted April 15, 2017 Author Posted April 15, 2017 @opentype Thank you! It is almost what I want to archive. There are two issues left: The link is: http://www.midgard-forum.de/forum/uploads/monthly_04_2017/2016%2011%20Midgard%20Lernkosten%20Zauberschutz%20und%20Zaubermittel%20M5%20v1.21.ods.413025493ee2e741b72bddabd2f4b0b1 But it should be: http://www.midgard-forum.de/forum/applications/cms/interface/file/file.php?record=1593&database=1&file=monthly_04_2017%2F2016%252011%2520Midgard%2520Lernkosten%2520Zauberschutz%2520und%2520Zaubermittel%2520M5%2520v1.21.ods.413025493ee2e741b72bddabd2f4b0b1 I don't allow deep links, since I want to have an authority check. The second issue is the file name. Can I have the file name instead of the path to that file?
hjmaier Posted April 15, 2017 Author Posted April 15, 2017 Thank you again. It works almost. The following part should be built dynamically: http://www.midgard-forum.de/forum/applications/cms/interface/file/file.php?record=1593&database=1 Since the record ID is the Record number from a specific article. I could live with the fixed URL and database=1, since it looks for every article the same, but the record ID will change with every article. And: Is there a way to retrieve the file name itself?
hjmaier Posted April 15, 2017 Author Posted April 15, 2017 14 minutes ago, opentype said: Just the file name is in {$anhang} of course. In {$anhang} is not the filename. It is the "internal" name. It looks like this: monthly_04_2017/2016 11 Midgard Lernkosten Zauberschutz und Zaubermittel M5 v1.21.ods.413025493ee2e741b72bddabd2f4b0b1 While the filename is: 2016 11 Midgard Lernkosten Zauberschutz und Zaubermittel M5 v1.21.ods But thank you for your help! I don't want to sound too demanding.
Daniel F Posted April 15, 2017 Posted April 15, 2017 @opentypes code should work. So, when you use <p><a href="{file='$anhang' extension='cms_records'}">{$anhang}</a></p> it returns http://www.midgard-forum.de/forum/uploads/monthly_04_2017/2016%2011%20Midgard%20Lernkosten%20Zauberschutz%20und%20Zaubermittel%20M5%20v1.21.ods.413025493ee2e741b72bddabd2f4b0b1 What's wrong with this? Do you need http://www.midgard-forum.de/forum/applications/cms/interface/file/file.php?record=1593&database=1 because of the permission check?
opentype Posted April 15, 2017 Posted April 15, 2017 27 minutes ago, hjmaier said: In {$anhang} is not the filename. It is the "internal" name. No, there is no internal name. There is just one filename, which is directly saved and accessed in the Pages database. It’s not a pretty name meant to be shown to users, but that’s the way it is in 4.x.
hjmaier Posted April 15, 2017 Author Posted April 15, 2017 @Daniel F Yes. For the permission check. The code @opentype posted works, beside the problem with the record number and the "real" filename. I checked that on my site. Here a screenshot: It shows me the "internal" filename. That is being pulled from the cms_custom_database_1 table: The "real" filename is in the core attachment table: If it isn't possible to retrieve that filename, I can live with that. But well, it looks ugly. Thank you for your help
Recommended Posts
Archived
This topic is now archived and is closed to further replies.