hi
i'm trying to create a custom display view like event calendar.
My db table named "events" is made by columns : id, date, event_type.
Therefore not all day (date column) have an event, so in the db table is not stored the row with a "empty day".
So in the db table i don't have all sequence of calendar dates.
How can i display a range al dates including the "empty dates" that not appair in my db table ?
I would not insert "day by day" in the table in the there aren't events in some days, because too many rows.
what is the best solution
thanks !
i'm trying to create a custom display view like event calendar.
My db table named "events" is made by columns : id, date, event_type.
Therefore not all day (date column) have an event, so in the db table is not stored the row with a "empty day".
So in the db table i don't have all sequence of calendar dates.
How can i display a range al dates including the "empty dates" that not appair in my db table ?
I would not insert "day by day" in the table in the there aren't events in some days, because too many rows.
what is the best solution
thanks !
Hi mattiad,
You will need some custom coding to do this. You will need to check the data you have retrieved from the table, find the first and last dates and use some PHP - probably in the Header box of your listing to insert the missing 'blank' entries. There are some PHP functions that will help with this (see here or here for example - they may need to be enabled in your server setup)
Bob
You will need some custom coding to do this. You will need to check the data you have retrieved from the table, find the first and last dates and use some PHP - probably in the Header box of your listing to insert the missing 'blank' entries. There are some PHP functions that will help with this (see here or here for example - they may need to be enabled in your server setup)
Bob
thx Bob
but in "header code" box i haven't access to $row['model']['field'] objects, so i can't build the custom table.
In my opinion the amount of $row objects must depend from my dates range, not from the query result. So in the "body code" box i could have a $row object for each date in my range.
So i think i have to create my custom $row objects in "front list" > "settings" > "pre display processing".
is it the fight way ?
If so, how can i create some $row object by my php code, not from query result ?
but in "header code" box i haven't access to $row['model']['field'] objects, so i can't build the custom table.
In my opinion the amount of $row objects must depend from my dates range, not from the query result. So in the "body code" box i could have a $row object for each date in my range.
So i think i have to create my custom $row objects in "front list" > "settings" > "pre display processing".
is it the fight way ?
If so, how can i create some $row object by my php code, not from query result ?
Hi mattiad,
I think that you have access to all of the values from the header row - just not in $row. Try putting this in the Header box and you should see the data
Bob
I think that you have access to all of the values from the header row - just not in $row. Try putting this in the Header box and you should see the data
<?php
echo'<div>$this->view->vars[rows]: '.print_r($this->view->vars['rows'], true).'</div>';
?>
Bob
thx Bob
to make a sample i tried to put this code in header box:
the print_r() show me the correct adding of the the row, but in the listing i see only the rows retrived from the query, without my custom adding.
(in "pre display processing" box seems to no have access to $this->view->vars[rows'] object so i can't manipulate it from that box)
to make a sample i tried to put this code in header box:
$this->view->vars[rows'][]=$this->view->vars['rows']['0'];
print_r($this->view->vars[rows']);
the print_r() show me the correct adding of the the row, but in the listing i see only the rows retrived from the query, without my custom adding.
(in "pre display processing" box seems to no have access to $this->view->vars[rows'] object so i can't manipulate it from that box)
HI Mattiad,
How are you trying to manipulate it exactly?
Can you post the out put from the print_r() here please so I can see what you are working with.
Bob
How are you trying to manipulate it exactly?
Can you post the out put from the print_r() here please so I can see what you are working with.
Bob
in the header box i try to manipulate the whole query (to try) inserting the code :
As you can see in the print_r() there is the object just added by me. So now the $this->view->vars[rows] object have a $row object in more than before (so 1 more then the query result).
But as you can see the "$this->view->vars[rows]" object have 5 $rows but in listing i see only 4 rows (the real query result).
<?php
$this->view->vars['rows'][]=$this->view->vars['rows']['0']; //add a $row whith a copy of first
echo '<div>$this->view->vars[rows]:<br> '.print_r($this->view->vars['rows'], true).'</div>';
?>
As you can see in the print_r() there is the object just added by me. So now the $this->view->vars[rows] object have a $row object in more than before (so 1 more then the query result).
$this->view->vars[rows]:
Array ( [0] => Array ( [ferieModel] => Array ( [date] => 31-12-2015 [user_id] => 235 [id] => 21 ) ) [1] => Array ( [ferieModel] => Array ( [date] => 27-09-2015 [user_id] => 235 [id] => 25 ) ) [2] => Array ( [ferieModel] => Array ( [date] => 28-09-2015 [user_id] => 235 [id] => 26 ) ) [3] => Array ( [ferieModel] => Array ( [date] => 29-09-2015 [user_id] => 235 [id] => 27 ) ) [4] => Array ( [ferieModel] => Array ( [date] => 31-12-2015 [user_id] => 235 [id] => 21 ) ) )

But as you can see the "$this->view->vars[rows]" object have 5 $rows but in listing i see only 4 rows (the real query result).
Hi mattiad,
I'm guessing here - the id of the record you've added is the same as one of the other records, What happens if you make that say 999 ?
Bob
I'm guessing here - the id of the record you've added is the same as one of the other records, What happens if you make that say 999 ?
Bob
$this->view->vars[rows]:
Array ( [0] => Array ( [ferieModel] => Array ( [date] => 31-12-2015 [user_id] => 235 [id] => 21 ) ) [1] => Array ( [ferieModel] => Array ( [date] => 27-09-2015 [user_id] => 235 [id] => 25 ) ) [2] => Array ( [ferieModel] => Array ( [date] => 28-09-2015 [user_id] => 235 [id] => 26 ) ) [3] => Array ( [ferieModel] => Array ( [date] => 29-09-2015 [user_id] => 235 [id] => 27 ) ) [4] => Array ( [ferieModel] => Array ( [date] => 31-12-2015 [user_id] => 235 [id] => 99 ) ) )
this did not solve the problem !
This topic is locked and no more replies can be posted.