Page 1 of 1

direct access to long comment of media-library

Posted: Thu Aug 14, 2008 1:25 pm
by mad-manne
Hi everyone,
I am modifying my templates\default\admin\media_showitem.tpl in order to fit my needs, but I'm sort of stuck trying to catch just one media-property(the long comment field) I'd like to see instead of cycling through all of the media-properties as it is done by default:

Code: Select all

{foreach from=$media.file.base_property key="prop_fieldname" item="prop_content"}
I have tried things like:
  • {$media.file.long_comment}
  • {$media.file.base_property.long_comment}
  • {$media.file.base_property.comment_long}
, but to no avail so far :?

I also did some search but apparently i tried the wrong search-terms ...

Does anyone know an answer ?

Cheers,
Manfred.

Posted: Thu Aug 14, 2008 2:05 pm
by judebert
Okay, as I understand it, the $media.file.base_property has a bunch of prop_fieldname groups attached to it. Each prop_fieldname group contains a label, a val, a type, and a title. The label is a language-specific string for the title; the val is the content; the type is whether it's a string, number, or whatnot.

Confused yet? Here's what it comes down to: you'll need to loop through all the prop_fieldname groups and find the one with the title 'comment2'. Right now (if I'm reading your request and the code correctly), we loop through the groups and print all of them, as long as they have a value. You want only the comment2. So change:

Code: Select all

                {foreach from=$media.file.base_property key="prop_fieldname" item="prop_content"}
                {if $prop_content.val}
                    <dt>{$prop_content.label}</dt>
                    <dd>{$prop_content.val|@escape}</dd>
                {/if}
                {/foreach}
 
to this:

Code: Select all

                {foreach from=$media.file.base_property key="prop_fieldname" item="prop_content"}
                {if $prop_content.title == 'comment2'}
                    <dt>{$prop_content.label}</dt>
                    <dd>{$prop_content.val|@escape}</dd>
                {/if}
                {/foreach}
 

Posted: Thu Aug 14, 2008 2:41 pm
by mad-manne
judebert wrote:Here's what it comes down to: you'll need to loop through all the prop_fieldname groups and find the one with the title 'comment2'.
I already "feared", that this was going to be the solution :roll:

Actually I had to look for COMMENT2, so that's how it looks like now:

Code: Select all

{if $prop_content.title == 'COMMENT2'}
    {$prop_content.val|@escape}
{/if}
Thanks for your help,
Manfred.

Posted: Thu Aug 14, 2008 2:42 pm
by judebert
Congratulations; I'm glad that's sorted out.