Dynamic Fields PM <-> DTL

Moderator: crythias

Locked
cetama
Znuny newbie
Posts: 3
Joined: 01 Oct 2014, 15:11
Znuny Version: 3.2.2

Dynamic Fields PM <-> DTL

Post by cetama »

Hi,

we are trying to modify the HTML output of the dynamic fields in the AgentTicketZoom.dtl. So what we want to achieve is that for a specific dynamic field name we want to add an id to the corresponding HTML tag. What I have learned so far is that it is not possible to add a condition to the dtl file (We are using OTRS > 3.2). So I think we have to modify the corresponding AgentTicketZoom.pm. I think I found the correct position:

Code: Select all

    # output dynamic fields in the sidebar
    for my $Field (@FieldsSidebar) {

        $Self->{LayoutObject}->Block(
            Name => 'TicketDynamicField',
            Data => {
                Label => $Field->{Label},
            },
        );

        if ( $Field->{Link} ) {
            $Self->{LayoutObject}->Block(
                Name => 'TicketDynamicFieldLink',
                Data => {
                    %Ticket,

                    # alias for ticket title, Title will be overwritten
                    TicketTitle    => $Ticket{Title},
                    Value          => $Field->{Value},
                    Title          => $Field->{Title},
                    Link           => $Field->{Link},
                    $Field->{Name} => $Field->{Title},
                },
            );
        }
        else {
            $Self->{LayoutObject}->Block(
                Name => 'TicketDynamicFieldPlain',
                Data => {
                    Value => $Field->{Value},
                    Title => $Field->{Title},
                },
            );
        }
    }
But I do not really understand the link between this for loop and the DTL definition. So how can I modify the HTML output? Do I have to modify the DTL and the loop? I am a little bit lost here - any help would be great?

Thanks,
cetama
Last edited by crythias on 01 Oct 2014, 15:32, edited 1 time in total.
Reason: [code] tags
crythias
Moderator
Posts: 10170
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Dynamic Fields PM <-> DTL

Post by crythias »

A rendered Dynamic Field in AgentTicketZoom looks like this:

Code: Select all

<fieldset class="TableLike FixedLabelSmall Narrow">

                        <label>DynamicField Label(display):</label>
                        <p class="Value">

                            <span title="FieldValue"><a href="optional link" target="_blank" class="DynamicFieldLink">FieldValue</a></span>

                        </p>
                        <div class="Clear"></div>
                    </fieldset>
This corresponds to Kernel/Output/HTML/Standard/AgentTicketZoom.dtl:

Code: Select all

                    <fieldset class="TableLike FixedLabelSmall Narrow">
<!-- dtl:block:TicketDynamicField -->
                        <label>$Text{"$Data{"Label"}"}:</label>
                        <p class="Value">
<!-- dtl:block:TicketDynamicFieldLink -->
                            <span title="$QData{"Title"}"><a href="$Data{"Link"}" target="_blank" class="DynamicFieldLink">$Data{"Value"}</a></span>
<!-- dtl:block:TicketDynamicFieldLink -->
<!-- dtl:block:TicketDynamicFieldPlain -->
                            <span title="$QData{"Title"}">$Data{"Value"}</span>
<!-- dtl:block:TicketDynamicFieldPlain -->
                        </p>
                        <div class="Clear"></div>
<!-- dtl:block:TicketDynamicField -->
                    </fieldset>
what it means is that a good place to put an ID is within a span or "a" markup :

Code: Select all

<span title="$QData{"Title"}"><a href="$Data{"Link"}" target="_blank" class="DynamicFieldLink">$Data{"Value"}</a></span>
That's the where. As for the How? Well, your view of what's provided indicates *only* Title (display), Value, and Link(web address) are being passed (regardless of naming of variables). *An* answer would to be to test $Data{"Name"} or make sure it's in the Block. I'm a bit backlogged right now, but you're on the right track.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
cetama
Znuny newbie
Posts: 3
Joined: 01 Oct 2014, 15:11
Znuny Version: 3.2.2

Re: Dynamic Fields PM <-> DTL

Post by cetama »

Hi,

@crythias thanks for the update. Yes I think this is the right place as well. The question is as you mentioned the *How*. This was also my idea to test the $Data{"Name"} within the corresponding *.pm file. But then I am a little bit stucked - I just want to add the id to the <span> or <a> tag if the name fits a specific condition. And as far as I now it is not possible to add conditions to the DTL file.

Thanks in advance,
cetama
Locked