Use JMFilePicker in the News Module

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Use JMFilePicker in the News Module

Post by Jeff »

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:

Code: Select all

if($jmfp = cmsms()->GetModuleInstance('JMFilePicker')) 
{      
      echo $jmfp->CreateFilePickerInput( $jmfp, $params['id'],$params['name'], $params['value'], $params, $params['returnid'] );
}
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:

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'}
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

Code: Select all

        {else}
          {$field->name}:&nbsp;{$field->value}
        {/if}
with

Code: Select all

        {elseif $field->name == 'FIELDNAME'}
            <img src="{uploads_url}/YOURDIR/{$field->value}"/>
        {else}
          {$field->name}:&nbsp;{$field->value}
        {/if}
Replace the FIELDNAME and YOURDIR as you did with editarticle.tpl.
Locked

Return to “Tips and Tricks”