Hi community,
I want to fill a table in the DTL template with data retrieved from a webservice in XML. What I can't figure out is what kind of format is required for the return hash. I've been looking and trying for two days now and I don't seem to get anywhere.
How to retrieve the information is not the problem. That works.
Can you just give me a "hardcoded" example of what the hash /array or whatever needs to look like?
Thank you,
Christian
[SOLVED] Filling DTL table with data
-
- Znuny newbie
- Posts: 49
- Joined: 22 May 2014, 19:19
- Znuny Version: 3.3.7
[SOLVED] Filling DTL table with data
Last edited by christian82 on 22 Jul 2015, 13:03, edited 1 time in total.
-
- Moderator
- Posts: 10169
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Filling DTL table with data
How would you do this if it wasn't OTRS?
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
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
-
- Znuny newbie
- Posts: 49
- Joined: 22 May 2014, 19:19
- Znuny Version: 3.3.7
Re: Filling DTL table with data
I would create an array:
row1 =>
StartDate => <some date>,
EndDate => <some date>,
row2 =>
StartDate => <some date>,
EndDate => <some date>,
And so on. But when I do this it only shows "Hash...something" instead of multiple rows.
If I create an array of arrays
StartDate => ['some date' 'another date'],
EndDate => ['some date' 'another date'],
I get an error message by OTRS.
If I create an array
StartDate => <some date>,
EndDate => <some date>,
StartDate => <some date>,
EndDate => <some date>,
It shows the correct dates, but it doesn't show me more then on row, as the previous row is overwritten.
At the moment I'm trying to figure out the correct format and hardcode the information so the only issue is with the correct format...
What a dillema...
row1 =>
StartDate => <some date>,
EndDate => <some date>,
row2 =>
StartDate => <some date>,
EndDate => <some date>,
And so on. But when I do this it only shows "Hash...something" instead of multiple rows.
If I create an array of arrays
StartDate => ['some date' 'another date'],
EndDate => ['some date' 'another date'],
I get an error message by OTRS.
If I create an array
StartDate => <some date>,
EndDate => <some date>,
StartDate => <some date>,
EndDate => <some date>,
It shows the correct dates, but it doesn't show me more then on row, as the previous row is overwritten.
At the moment I'm trying to figure out the correct format and hardcode the information so the only issue is with the correct format...
What a dillema...
-
- Moderator
- Posts: 10169
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Filling DTL table with data
let me rephrase my question... You are asking how to fill a dtl table with data. I'm asking you how you'd fill a table with data if it were HTML.
What have you tried? How is the source data generated? What dtl table are you trying to fill? how are you making the attempt? What's your current code modification? Where did you get the information for the attempt you're trying?
What have you tried? How is the source data generated? What dtl table are you trying to fill? how are you making the attempt? What's your current code modification? Where did you get the information for the attempt you're trying?
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
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
-
- Znuny newbie
- Posts: 49
- Joined: 22 May 2014, 19:19
- Znuny Version: 3.3.7
Re: Filling DTL table with data
Well, in HTML I would print the tags (table, thead, tr, td,...) and fill in the date where appropriate...
What have you tried?
Search on Google, this Forum; Different ways to setuo my Array; look at the OTRS developer documentation
How is the source data generated?
Hardcoded right now. When functional retrieved from a webservice.
What dtl table are you trying to fill?
A completely new one. Tried an altered example from the developer Manual. https://otrs.github.io/doc/manual/devel ... html#block
how are you making the attempt?
See source code below
What's your current code modification?
See source code below
Where did you get the information for the attempt you're trying?
From the developer Manual. https://otrs.github.io/doc/manual/devel ... html#block
What have you tried?
Search on Google, this Forum; Different ways to setuo my Array; look at the OTRS developer documentation
How is the source data generated?
Hardcoded right now. When functional retrieved from a webservice.
What dtl table are you trying to fill?
A completely new one. Tried an altered example from the developer Manual. https://otrs.github.io/doc/manual/devel ... html#block
how are you making the attempt?
See source code below
What's your current code modification?
See source code below
Where did you get the information for the attempt you're trying?
From the developer Manual. https://otrs.github.io/doc/manual/devel ... html#block
Code: Select all
# Kernel/Modules/AgentHelloWorld.pm - frontend module
my %Entitlement =(
"StartDate"[0] => "Test1",
"StartDate"[1] => "Test2",
);
$Self->{LayoutObject}->Block(
Name => 'OverviewResultRow',
Data => {
%Entitlement,
},
);
Code: Select all
# Kernel/Output/HTML/Standard/AgentHelloWorld.dtl
<table class="DataTable">
<thead>
<tr>
<th>$Text{"Name"}</th>
<th>$Text{"Type"}</th>
<th>$Text{"Comment"}</th>
<th>$Text{"Valid"}</th>
<th>$Text{"Changed"}</th>
<th>$Text{"Created"}</th>
</tr>
</thead>
<tbody>
<!-- dtl:block:NoDataFoundMsg -->
<tr>
<td colspan="6">
$Text{"No data found."}
</td>
</tr>
<!-- dtl:block:NoDataFoundMsg -->
<!-- dtl:block:OverviewResultRow -->
<tr>
<td></td>
<td>$Text{"$QData{"StartDate"}"}</td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<!-- dtl:block:OverviewResultRow -->
</tbody>
</table>
-
- Moderator
- Posts: 10169
- Joined: 04 May 2010, 18:38
- Znuny Version: 5.0.x
- Location: SouthWest Florida, USA
- Contact:
Re: Filling DTL table with data
For example, this is what AgentTicketZoom does on the .dtl side for a table. Note the <!-- dtl:block:TreeItem --> for the tr and <!-- dtl:block:TreeItemEntryName --> for each content block, more or less.
Its counterpart is in Modules/AgentTicketZoom.pm which you can see basically says:
For each row, gather data and populate a block (which prints.)
Its counterpart is in Modules/AgentTicketZoom.pm which you can see basically says:
For each row, gather data and populate a block (which prints.)
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
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
-
- Znuny newbie
- Posts: 49
- Joined: 22 May 2014, 19:19
- Znuny Version: 3.3.7
Re: Filling DTL table with data
Gotcha!
I thought, that I only had to populate one single block with all rows in it, not one block for each row...
Changed the source code to:
I get the 10 rows displayed as requested! So all I have to do is to parse the XML Response that each desired row Returns a block... duh!!
Thank alot!
I thought, that I only had to populate one single block with all rows in it, not one block for each row...
Changed the source code to:
Code: Select all
for (my $i=0; $i<10; $i++){
my %Entitlement =(
"StartDate" => $i,
);
$Self->{LayoutObject}->Block(
Name => 'OverviewResultRow',
Data => {
%Entitlement,
},
);
}
I get the 10 rows displayed as requested! So all I have to do is to parse the XML Response that each desired row Returns a block... duh!!
Thank alot!