How to make a resource for a few extra TV fields?

On the website in the resource need to bring a few options HEADER, the DATE, the PICTURE ON the FILE, DOWNLOAD AND VIEW the FILE IN OFFICE. I looked at a lot of solutions and MIGX TV but not found suitable.

Here's an example: 5a2f61110b16e628751903.jpeg

Just the TV box, to create can easily. Examples and articles are. But what I can't deal with this realization.
June 10th 19 at 15:44
2 answers
June 10th 19 at 15:46
Solution
Hello, just MIGX and fit, MIGX gives flexibility on the type of fields that is read by the example of slider https://dart.agency/blog/modx/modx-revo,-ispolzova...
Happened, but now I can't deal with the withdrawal date. Just do not displays all through the "inputTVtype": "date" - assunta_Stiedemann50 commented on June 10th 19 at 15:49
With the date figured out!

Is it possible to add a machine image file to the format determined or is it a script to write? Or at least just the option to make a dropdown list of images. - assunta_Stiedemann50 commented on June 10th 19 at 15:52
write a script that would be looking at the file extension and depending on the desired would produce the desired image.
You can try wood, but it's not really an option:
[[+file:reverse:limit=`3`:reverse:is=`pdf`:then=`<img src="/img1.png">`:else=`<img src="/img2.png">`]]

Here in the modifier I deploy the file to the extension was in the beginning and are cut to 3 characters and back unfold and compare with the pdf and bring the icon to a pdf, and other extensions will be different. - maud_F commented on June 10th 19 at 15:55
But if, as an example

[[!getFileInfo? &file=`[[*tv_file]]`]]

And the snippet about this

$fileInfo = array();
$fileInfo['filesize'] = filesize($file);
$tmp = explode('.',$file);
$fileInfo['fileExt'] = end($tmp);
$modx->setPlaceholders($fileInfo);

Therefore, the available 2 the placeholder for the page [[+filesize]] and [[+fileExt]].

5a322db73f892414457106.jpeg
But it does not work on my why! Vyderaet all rows of the array. And takes is why the extension of the last file. - assunta_Stiedemann50 commented on June 10th 19 at 15:58
Hello, the snippet needs to convey not TV, and the MIGX, i.e. MIGX template check run:
[[!getFileInfo? &file=`[[+file]]`]] - maud_F commented on June 10th 19 at 16:01
In this case, simply do not go! Want to finish this question)))

Here check:
[[!getFileInfo? 
&file=`[[+file]]`
]]


Template:
<li class="active audio_item">
 <div class="clearafter">
 <div class="audio_item_name">[[+name]]</div><br>
 <div class>, updated: [[+date:strtotime:date=`%Y-%m-%d`]]</div>
 [[+fileExt]]<a href="[[+file]]">Download</a>
 <a href="https://docs.google.com/viewer?url=[[!++site_url]][[+file]]" target="_blank">view</a>


</div>
</li>


Snippet
<?php
$fileInfo = array();
$fileInfo['filesize'] = filesize($file);
$tmp = explode('.',$file);
$fileInfo['fileExt'] = end($tmp);
$modx--->setPlaceholders($fileInfo);


5a3239aa95e5a931792798.jpeg

Still I think it in the snippet but can't understand what exactly - assunta_Stiedemann50 commented on June 10th 19 at 16:04
and you have the snippet outputs where validation? You need to see the file extension depending on need to display something, for example, a picture with the icon.
And your snippet it is not clear what it does :)
Here, for example, the snippet determine the size of the file (and extension), view and based on your make:

Code snippet: fileInfo:
<?php
$rootPath = strval($_SERVER['DOCUMENT_ROOT']);
$filePath = strval($modx--->getOption('filePath', $scriptProperties, false));
$file = $rootPath .'/'. $filePath;

if($file) {
 $fileExt = pathinfo($file, PATHINFO_EXTENSION);
 $fileSize = filesize(strval($file));

 if($fileSize > 1024){
 $fileSize = ($fileSize/1024);
 if($fileSize > 1024){
 $fileSize = ($fileSize/1024);
 if($fileSize > 1024) {
 $fileSize = ($fileSize/1024);
 $fileSize = round($fileSize, 1);
 return "." . $fileExt ." (". $fileSize ." GB)";
 } else {
 $fileSize = round($fileSize, 1);
 return "." . $fileExt ." (". $fileSize ." MB)";
}
 } else {
 $fileSize = round($fileSize, 1);
 return "." . $fileExt ." (". $fileSize ." KB)";
}
 } else {
 $fileSize = round($fileSize, 1);
 return "." . $fileExt ." (". $fileSize ." B)";
}
}


The output of the snippet:
<p>Size of the file - [[!fileInfo?file=`[[++assets_path]]tpl/css/style.css`]]</p>
- maud_F commented on June 10th 19 at 16:07
thank you! - assunta_Stiedemann50 commented on June 10th 19 at 16:10
June 10th 19 at 15:48
Solution
That's what happened 5a310c9432c68215330390.jpeg

Form tabs:
[
{
 "caption": "Title",
 "fields": [
{
 "field": "file",
 "caption": "File",
 "inputTVtype": "file"
},
{
 "field": "name",
 "caption": "Name",
 "inputTVtype": "text"
},
{
 "field": "date",
 "caption": "date",
 "inputTVtype": "date"
}
]
}
]


The column layout:
[{
 "header": "File",
 "dataIndex": "file"
},{
 "header": "Name",
 "dataIndex": "name"
},{
 "header": "date", 
 "width": "100", "sortable": "true", "dataIndex": "date"}
]


Template:
<li class="active audio_item">
 <div class="clearafter">
 <div class="audio_item_name">[[+name]]</div><br>
 <div class>[[+date:strtotime:date=`%Y-%m-%d`]]</div>
 <a href="[[+file]]" controls>download</a>
 <a href="http://view.officeapps.live.com/op/view.aspx?src=[[!++site_url]][[+file]]" controls>view</a>


</div>
</li>


Conclusion:
[[!getImageList?
&tvname=`addfile`
&tpl=`addfileTpl`
&docid=`[[*id]]`
&limit=`999`
]]
The date is not clear in the forms Tab is written "field": "Date", and call [[+date:strtotime:date=`%Y-%m-%d`]] (register to another, although this is not important, most likely).
Print without the modifier :strtotime, e.g., [[+date:date=`%d.%m.%Y`]], watch what and how.
To determine the pictures need a snippet would be watching the file extension and set the picture. - assunta_Stiedemann50 commented on June 10th 19 at 15:51
With the date figured out!

Is it possible to add a machine image file to the format determined or is it a script to write? Or at least just the option to make a dropdown list of images for each link. - assunta_Stiedemann50 commented on June 10th 19 at 15:54

Find more questions by tags MODX