×

Notice

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

TOPIC: Modify com_hotspots\helpers\hotspot.php

Modify com_hotspots\helpers\hotspot.php 9 years 11 months ago #29388

  • Erwin de Wolff
  • Erwin de Wolff's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 74
  • Thank you received: 0
Hi Daniel,

I have a question about my customized version I have for Hotspots.
Currently I'm modifying com_hotspots\helpers_hotspot.php in order to get more information out of the database into the marker information window.

The part I'm modifying is:

public static function prepareHotspotForJsonOutput($hotspot, $users = array())
{
$description = preg_replace("@[\\r|\\n|\\t]+@", '', $hotspot->description_small);
$address = self::formattedAddress($hotspot);
$jsonHotspot = array(
'id' => (int) $hotspot->hotspots_id,
'catid' => (int) $hotspot->catid,
'lat' => (float) $hotspot->gmlat,
'lng' => (float) $hotspot->gmlng,
'title' => $hotspot->name,
'cutDescription' => CompojoomHtmlString::truncateComplex($description, 100),
'description' => $description,
'linkDescription' => $hotspot->description,
'street' => $hotspot->street,

);

I added the variable linkDescription. The reason that I'm doing this, is that in my marker description a link is added to the belonging article on the website. This link is put in the marker description as a function of "read-more", the part below "read-more" is automaticly split up and stored in the $hotspot->description field. Since I need that part in the marker-window, I added this in order to get the information from the database.

I was wondering, would it be possible to implement this database in the helper.php file for future releases?

Kind Regards,

Erwin

Modify com_hotspots\helpers\hotspot.php 9 years 11 months ago #29389

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
I would advise against making modifications to the helper files. Instead. Do your modification in a template override. This way you can control what's happening. And a template override won't be overridden during the update - worst case ->you'll have to change it one day because something else has changed, but that is way easier than overriding core files.

Regards,
Daniel

Modify com_hotspots\helpers\hotspot.php 9 years 11 months ago #29390

  • Erwin de Wolff
  • Erwin de Wolff's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 74
  • Thank you received: 0
Hi Daniel,

Thanks for your answer,
If I can achieve the same result with a template override, then that is definitely a better way to go.
I'll look into that, thanks!

Kind Regards,

Erwin

Modify com_hotspots\helpers\hotspot.php 9 years 11 months ago #29391

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Yes, you can! I've done it myself last week for a customer :)

Modify com_hotspots\helpers\hotspot.php 9 years 11 months ago #29403

  • Erwin de Wolff
  • Erwin de Wolff's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 74
  • Thank you received: 0
Hi Daniel,

Would you be so kind to help me a little bit?
I've been trying to fix this with a template override, but:
- as far as I can see the helpers file are not overrideable?
- how can I access "$hotspot->description" out of com_hotspots\views\hotspots\tmpl\default_hotspot.php?
I've tried: $hotspot->description and also $this->$hotspot->description but none of them seem to work.
Do you have any ideas?

Kind Regards,

Erwin

Modify com_hotspots\helpers\hotspot.php 9 years 11 months ago #29404

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey Erwin,
You are overriding the wrong file :P
Everything in the hotspots view is a template. But the helper that you want to override is only called from the json view. The json view is being called from the hotspots view with an ajax request to fetch the data.
jsonv5/tmpl -> there you'll see the call to the helper.
Regards,
Daniel

Modify com_hotspots\helpers\hotspot.php 9 years 11 months ago #29406

  • Erwin de Wolff
  • Erwin de Wolff's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 74
  • Thank you received: 0
Hi Daniel,

Okidoki, that makes a lot clear, thanks!

Kind Regards,

Erwin
  • Page:
  • 1
Time to create page: 0.114 seconds