pepebe
5/6/2014 - 10:17 AM

Repair id2path if a resource is displayed in context of another resource. Uses either the current +id placeholder or a custom id added as ou

Repair id2path if a resource is displayed in context of another resource. Uses either the current +id placeholder or a custom id added as output filter option.

<?php

/*
Repair id2path if a resource is displayed in context of another resource. 
Uses either the current +id placeholder or a custom id added as output filter option.

Example for getResources:
[[+ImageTv:fixPath]]

Example for fastfield:
[[#1.tv.ImageTv:fixPath=`100`]]
*/

if(!empty($options)){
   $docid = $options;
}
else{
   $docid = $modx->getPlaceholder('id');
}

$path = $modx->runSnippet(
    'id2path'
   ,array(
        'docid' => $docid
       ,'pathTpl' => 'assets/resources/{tree}' 
   )
);

return $path.basename($input);