Last visited Reservation Assets Module

More
8 years 11 months ago #5575 by fabrikastyle
Last visited Reservation Assets Module was created by fabrikastyle
Hi!
I would like to share my solution about module of Last visited Reservation Assets (who use HUB component). This is a very simple solution, but it requires your advice. To collect information about the last visited hotel I use Joomla Session parameter (JFactory::getSession).
1. In the template of reservation asset '/components/com_solidres/views/reservationasset/tmpl/default.php' at the file bottom I added the code to collect information (name of the hotel, photo, location, and link to the page):
<?php
$session = JFactory::getSession();
$mylink = $session->get("mylink", array());
$newlink = $this->item->name;
$newlink = JRoute::_('index.php?option=com_solidres&view=reservationasset&id='.$this->item->id, true, false);
$newlink = $this->item->media[0]->value;
$newlink = $this->item->city;
if (!in_array($newlink, $mylink)){
if (count($mylink)==5) array_shift($mylink); //It will take only 5 last visited
$mylink[] = $newlink;
$session->set("mylink", $mylink);
}
?>

2. Then i Make a small module that shows the result of this session in the module. It should be installed and published. (module in attache)
By default, I added the last 5 hotels. I have write it directly in the code.
But most likely it can be done as a parameter of the module.
That is all. At this stage, I was happy with everything :).
But if this is an acceptable solution, is it possible to add code to the page of the reservation asset automatically? May be with some plugin... I do not know codding and programming.

Best regards.

This attachment is hidden for guests.
Please log in or register to see it.

This message has an attachment file.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #5576 by fabrikastyle
Replied by fabrikastyle on topic Last visited Reservation Assets Module
Here is demo prokarpaty.fabrikastyle.net/ru/cotage?vi...eservationasset&id=2
(First you shoud open some hotels :)

Please Log in or Create an account to join the conversation.

More
8 years 11 months ago #5580 by vietvh
Replied by vietvh on topic Last visited Reservation Assets Module
Hi,

First I have to say that your modification looks awesome!

About the usage of JFactory::getSession(), I think it is better to use

Where $context = 'com_solidres.reservation.process';

That makes it looks the same with the rest of Solidres system.

Method setUserState calls JFactory::getSession() in the background too.
$newlink = $this->item->name;
$newlink = JRoute::_('index.php?option=com_solidres&view=reservationasset&id='.$this->item->id, true, false);
$newlink = $this->item->media[0]->value;
$newlink = $this->item->city;

I am not sure about this code, should it be like this instead?
$newlink = $this->item->name;
$newlink .= JRoute::_('index.php?option=com_solidres&view=reservationasset&id='.$this->item->id, true, false);
$newlink .= $this->item->media[0]->value;
$newlink .= $this->item->city;

Nice idea, we will looking to add a plugin event into reservation asset view (may be in v0.9.0), so you can inject your code automatically without manually modifying.

Regards,

Please Log in or Create an account to join the conversation.

Moderators: solidres
Powered by Kunena Forum

All the things you need to make your work easier. Did you like Solidres?