[solved] Listit Extended (listit2) file download link

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
hunter58
New Member
New Member
Posts: 8
Joined: Sat Mar 30, 2013 12:15 am

[solved] Listit Extended (listit2) file download link

Post by hunter58 »

Hi,
I'm using CMS:MS 1.11.5 and the 1.4 beta1 ListIt2 module.
In my fielddef are two fields for uploading files (a pdf and a midi file btw) to seperate the uploads I use two different directories for upload in the customfieldsetting (pdf and midi)
On entering data everything works fine and files are uploaded to {upload_dir}pdf and {upload_dir}midi directory.

On retrieving data the template (default summary) creates a link to the files but without the directory. It creates a reference to the {upload_dir} and won't append the directory.
I checked with {print_r} and in the fielddefs there is an item options.dir so I should alter the template te add the directory, but somehow I'm doing something wrong because whatever I try I can't adress the directoryfield in the fielddefs.
$fielddef.options[dir] should do it but that gives me an empty field.
Last edited by hunter58 on Wed Apr 10, 2013 3:50 pm, edited 1 time in total.
Stikki

Re: Listit Extended (listit2) file download link in template

Post by Stikki »

You can access FielddefBase API methods via exact path to object

ie:
if field alias is: myfile
{$item->fielddefs.myfile->GetOptionValue('dir')}

same with ID aproach:
{$item->fielddefs.47->GetOptionValue('dir')}

or you can install ListItExtended XDefs module and use GBFilePicker field, that saves dir as part of value.
hunter58
New Member
New Member
Posts: 8
Joined: Sat Mar 30, 2013 12:15 am

Re: Listit Extended (listit2) file download link in template

Post by hunter58 »

Thanks for a clear and rapid respons.

So if I understand correctly I can access aany field using:

Code: Select all

{$item->fielddefs.{$fielddef.alias}->GetOptionValue('attrib')}
Stikki

Re: Listit Extended (listit2) file download link in template

Post by Stikki »

I gave you clear instructions, try to understand em.

Is this alias of your field: {$fielddef.alias} ?

Yes you can, access ANY field property.
Stikki

Re: Listit Extended (listit2) file download link in template

Post by Stikki »

Okey,

More deeper example:

Let's create field:
Type: Text Input
Alias: price
Name: Price

Accessing this field in templates:
Get value: {$item->price}
Get value: {$item->fielddefs.price.value}
Get value: {$item->fielddefs.price->GetValue()}
Get option value of "max_lenght": {$item->fielddefs.price->GetOptionValue('max_lenght')}
Get type: {$item->fielddefs.price->GetType()}

And belive me we would write API documentations / instructions page, if neither me or uniqu3 would have time for it, but currently we both are too busy for that.

Best regards

-Stikki-
hunter58
New Member
New Member
Posts: 8
Joined: Sat Mar 30, 2013 12:15 am

Re: Listit Extended (listit2) file download link in template

Post by hunter58 »

Stikki wrote:I gave you clear instructions, try to understand em.

Is this alias of your field: {$fielddef.alias} ?

Yes you can, access ANY field property.
I did understand. I was cutting corners I think, sorry for that :o

What I ment was that if you put it in a template parsing each extra field you could use a parameter for alias substition like so:

Code: Select all

    {foreach from=$item->fielddefs item=fielddef}
        {if $fielddef.type == 'SelectFile'}
            {$fielddef.name|cms_escape}: <a href="{$uploads_url}/{$item->fielddefs.{$fielddef.alias}->GetOptionValue('dir')}/{$fielddef.value|cms_escape}">{$fielddef.value|cms_escape}</a><br />
.....
And yes that works, tried that :D

Gee I love Smarty ... and this forum

Again: thanks for helping me out
Post Reply

Return to “Modules/Add-Ons”