Jump to content

repeater: more than one set of data possible?


autobahn
 Share

Recommended Posts

hey community!

maybe i'm on the wrong way but here is what i'm trying to do:

  1. i have a page called "tickets" with a template "tickets_index" which only renders a list of the page's subpages.
  2. the subpages (aka "the tickets") uses the template "ticket" which outputs all the fields of a subpage (aka "a ticket").
  3. one of the ticket-template-fields is a repeater-field called "timesheets".
  4. this repeater-field uses the fields: ts_title, ts_desc, ts_starttime, ts_endtime.

Here is my code from template "ticket" which should output every set of data from the repeater-field of the ticket...

foreach ($page->timesheets as $timesheet_item){
$timesheet_item_list = '
<li class="clr_fx">
<div class="clr">
<div class="col_5">
<p class="clr_fx item title">
<label>Titel</label><span>'. $timesheet_item->ts_title .'</span>
</p>
<p class="clr_fx item">
<label>Beginn</label>'. $timesheet_item->ts_begin .'
</p>
<p class="clr_fx item">
<label>Ende</label>'. $timesheet_item->ts_end .'
</p>
<hr class="alt2">
<p class="clr_fx item calc_diff">
<label>Gesamt</label>
<span>'. get_time_difference($timesheet_item->ts_begin, $timesheet_item->ts_end) .'</span>
</p>
</div>
<div class="col_6">
<p class="item desc">
<label>Beschreibung</label>
<span>'. $timesheet_item->ts_desc .'</span>
</p>
</div>
</div>
</li>

';}

$timesheet = '<ol class="list_ticket_timesheet">'. $timesheet_item_list .'</ol>';
$content .= $timesheet;

...but as you can see (check the pictures below, too), it outputs only one set of data from the repeater.

i only see the repeater-dataset "test 1". but i wanna see "test 2", too. and maybe more.

did i missunderstood the field repeaters logic? - i mean: the sets are visible in edit-mode, so they seem to be somewhere ankered with the page->timesheets (well, as page in admin/repeaters/..., i know).

so, what do i have to change to make this working like it should?

thanks for your attention and best regards from Saxony/DE.

post-1665-0-21183700-1375252364_thumb.jp

post-1665-0-95608600-1375252364_thumb.jp

post-1665-0-85900600-1375252365_thumb.jp

post-1665-0-46618100-1375252366_thumb.jp

post-1665-0-54130200-1375252367_thumb.jp

Link to comment
Share on other sites

Hi autobahn and welcome!

I think you have a PHP (logic) problem.

You must initialize your $timesheet_item_list variable before the foreach loop, otherwise PHP doesn't know it afterwards (Scope).

Also you want to append the output of each loop to that variable.

// Initialize
$timesheet_item_list = '';

foreach ($page->timesheets as $timesheet_item){
  $timesheet_item_list .= '<li class="clr_fx">....'; // Note the dot before '='
  // ...
}
  • Like 3
Link to comment
Share on other sites

thank you a lot, wanze. i'am watching this community since february this year. its a pleasure for me to be part of such a lovely, decent and productive community - so i will do my part to it, too.

also thank you for your help. you're right, my variable is the problem.

i like such problems, because they are the base of my education. i'am autodidact - learning by doing, you know.

for this time, you're my php-coach. thanks a lot.

originally i'am lifeguard. since 2008 i run a little web&marketing-agency, because culture becomes canceled in germany more than more.

till february, i worked with joomla as my working-base. php never was something i want to learn more than necessary. but in fact, i had to.

joomla did the job, virtually. but its joomla, you know.

now, since i found pw & its fantastic sources (also forums etc.), php & me still getting friends.

I never thought that it could be so easy to be so flexible. :]

for me, pw is not only cmf/cms. pw is an attitude.

thanks to ryan & the pw-community!

and thank you wanze. ;]

best regards from the land of 'Plan B'.

peace!

000_2013-08-01_23-53-10.jpg

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...