Based on this line
<?php echo $this item->pto;?>
I thought it should be $this->item->pto, but apparently that is not the
case. Please look up how the code should actually look like. Just adding
random class members and overwriting variables will not help.
Am 10.08.2016 um 21:31 schrieb Viper:
> It's because $this object does not contain an item object. Add in the
> view class right after the
> |
> classViewpto....{
> |
> line
> |
> protected$item;
> |
>
> and if you want to access $this->item in the template you should assign
> this in the view method right before the parent::display(); like
> |
> $this->item =&$json;
> |
>
> I think that you need refer to the docs at
>
https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_a_view_to_the_site_part
> See the part where the view described and how the msg($this->msg)
> assigned to the view/template.
>
> On Wednesday, August 10, 2016 at 9:43:18 PM UTC+3,
ste...@gmail.com wrote:
>
> Thank you for the link Viper.
> As Hannes and Michael alluded too I added the $item =
> json_decode($this->item->pto);
>
> But it gave the error
> |
> undefinedproperty Viewpto::$item
> |
>
>
> If I try to dump the json it is empty.
>
>
> On Wednesday, August 10, 2016 at 2:11:10 PM UTC-4, Viper wrote:
>
> According to you question... After decoding json string using
> json_decode() you can access:
> objects like $json->date_of_hire
> arrays like $json['date_of_hire']
>
> Do and see
> |
> $json ='{"date_of_hire":["06-05-2012
> "],"prior_year_carry_over":["14"],"current_year_accrual":["15"],"pto_days_used":["6"],"pto_days_remaining":["23"]}';
> echo '<pre>';
> print_r(json_decode($json));
> echo '</pre>';
> |
>
> For accessing a date value you need just do $json->date_of_hire[0]
>
> More info about json format you can fine here
json.org
> <
http://json.org>
>
> On Wednesday, August 10, 2016 at 6:43:45 PM UTC+3,
>
ste...@gmail.com wrote:
>
> Michael, Hannes thank you for the nudge in the right direction.
>
> I have done this and now get an error undefined property
> Viewpto::$item
> |
> $item =json_decode($this->item->pto);
>
joomla-dev-gene...@googlegroups.com
> > <mailto:
joomla-dev-gene...@googlegroups.com>.
> <
https://groups.google.com/group/joomla-dev-general>.
> <
https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
joomla-dev-gene...@googlegroups.com
> <mailto:
joomla-dev-gene...@googlegroups.com>.