×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Coding Question

Coding Question 7 years 8 months ago #34588

  • Dima um
  • Dima um's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Hello Daniel,
I am adding some code to the hotspots view. I was wandering if you can help me with an issue:

I put my code here: components\com_hotspots\views\hotspots\tmpl\default_hotspot.php, the problem is that I do not have access tp php variables in this file,
mainly I need hotspot id. I need it in php, but there is only javascript format of {{ var}}.
Alternatively maybe a variable for this file can be generated for example in here: components\com_hotspots\helpers\hotspot.php ?

Thanks

Coding Question 7 years 8 months ago #34628

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
The hotspots view is used mainly for generated the structure for the page. On load we dynamically fetch the hotspots and replace the placeholders with the actual values. You won't find a hotspot id here. you'll need to do your thing with javascript if you need an id.

What are you trying to do?

Coding Question 7 years 8 months ago #34630

  • Dima um
  • Dima um's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
Well its like this:
There is another component that lets users rate articles or other content like hotspot in this case. ITs like 5 star rate system.
The info is stored in its own table with reference to hotspot id. So I get rating info from that table using id of the hotspot.
Since I don't havee access to the "id" in "components\com_hotspots\views\hotspots\tmpl\default_hotspot.php", I did the coding in
components\com_hotspots\helpers\hotspot.php and created variables to so I can display what I need in {{var}} format.
My code would have been a lot cleaner if I had id in default_hotspot.php..

Coding Question 7 years 8 months ago #34632

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
You can't have an id there. You would need to do this with javascript. Once the page is rendered you get a list with hotspots - this is where you have the ids. Then you do your request and fetch the ratings and will have to populate a template variable with those ratings. That is the way it can work. Hotspots is dynamic - the hotspots are different depending on the user's position on the map. We can't render a static list of hotspots in the default.php

Regards,
Daniel

Coding Question 7 years 8 months ago #34633

  • Dima um
  • Dima um's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 24
  • Thank you received: 0
I understand, thanks. I'll leave it as it is now, as long as its working))
  • Page:
  • 1
Time to create page: 0.110 seconds