- Posts: 87
COMMUNITY FORUM
Unable to access item reference in category.php
- Michael Yaeger
- Topic Author
- Offline
- Premium Member
Less
More
9 years 7 months ago #140679
by Michael Yaeger
Unable to access item reference in category.php was created by Michael Yaeger
I am trying to access item data in category.php by:
However, I'm only able to access this data after line 124 in my code: www.codeshare.io/fW9ZJ
You can see my attempt to access that data on line 33 and 123. Neither return a value. However, the same code at lines 125 and 376 do.
Why isn't the data accessible?
echo 'Item = '.$this->item->title;
echo $this->item->gallery;
However, I'm only able to access this data after line 124 in my code: www.codeshare.io/fW9ZJ
You can see my attempt to access that data on line 33 and 123. Neither return a value. However, the same code at lines 125 and 376 do.
Why isn't the data accessible?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 7 months ago #140691
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Unable to access item reference in category.php
This data is only accessible from within the loop (foreach). You can not access it otherwise.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Michael Yaeger
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 87
9 years 7 months ago - 9 years 7 months ago #140759
by Michael Yaeger
Replied by Michael Yaeger on topic Unable to access item reference in category.php
OK, I am able to access the item data by:Is there a better way to get the item reference without running this empty loop?
foreach($this->secondary as $key => &$item) {}
echo 'Item = '.$item->title;
echo $item->gallery;
Last edit: 9 years 7 months ago by Michael Yaeger.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 7 months ago #140767
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Unable to access item reference in category.php
This data should be accessed from that loop.
I would suggest that you look at how the default category/ category_items files work.
I would suggest that you look at how the default category/ category_items files work.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Michael Yaeger
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 87
9 years 7 months ago #140773
by Michael Yaeger
Replied by Michael Yaeger on topic Unable to access item reference in category.php
Actually, this data CAN be accessed outside that loop as long as the loop runs first, even if empty.
See lines 33-40 which work:
www.codeshare.io/fW9ZJ#33
See lines 33-40 which work:
www.codeshare.io/fW9ZJ#33
Please Log in or Create an account to join the conversation.