Use JMFilePicker in the News Module
Posted: Fri Feb 12, 2016 4:11 am
As I went to setup a live example I noticed that even though the function is written in module it hasn't been registered in Smarty (I should have paid more attention when testing). So until the next version you will need a UDT wrapper.
Add a new Field Definition to the News Module of type "Text Input"
Create an UDT named "JMFP" with the following code:
Copy the editarticle.tpl from /modules/News/templates and paste it in /module_custom/News/templates.
Edit /module_custom/News/templates/editarticle.tpl and replace line 184 with the following code:
For more params for the JMFP call read the JMFilePicker help.
Replace the FIELDNAME with the name of the Field Definition you created above.
Replace the YOURDIR with the directory you want to list/start at relative the /uploads/
In your detail template (you will have to adjust for the summary template) replace lines 115-117
with
Replace the FIELDNAME and YOURDIR as you did with editarticle.tpl.
Add a new Field Definition to the News Module of type "Text Input"
Create an UDT named "JMFP" with the following code:
Code: Select all
if($jmfp = cmsms()->GetModuleInstance('JMFilePicker'))
{
echo $jmfp->CreateFilePickerInput( $jmfp, $params['id'],$params['name'], $params['value'], $params, $params['returnid'] );
}
Edit /module_custom/News/templates/editarticle.tpl and replace line 184 with the following code:
Code: Select all
{if $field->prompt == 'FIELDNAME'}
{JMFP name=$field->nameattr value=$field->value dir='YOURDIR' }
{if !empty($field->value)} {$delete_field_val} <input type="checkbox" name="{$field->delete}" value="delete" />{/if}
{elseif $field->type == 'textbox'}
Replace the FIELDNAME with the name of the Field Definition you created above.
Replace the YOURDIR with the directory you want to list/start at relative the /uploads/
In your detail template (you will have to adjust for the summary template) replace lines 115-117
Code: Select all
{else}
{$field->name}: {$field->value}
{/if}
Code: Select all
{elseif $field->name == 'FIELDNAME'}
<img src="{uploads_url}/YOURDIR/{$field->value}"/>
{else}
{$field->name}: {$field->value}
{/if}