Welcome, Guest
Username: Password: Remember me

TOPIC: $20 for help: toolbar button to open new window

$20 for help: toolbar button to open new window 13 Jul 2013 09:16 #7949

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
Hi

I'm trying to build a custom toolbar button that will get all selected items, build a link to open into google map (route planning).

In my view.html.php I have added:
// Map
JToolBarHelper::customX('orders.getMap', 'map', 'map', "Google Map");

So I have my button on the view.

In my orders controller.php file I have added:
	public function getMap(){
	
		// Get the input
        $input = JFactory::getApplication()->input;
        $pks = $input->post->get('cid', array(), 'array');

        // Sanitize the input
        JArrayHelper::toInteger($pks);

        // Get the model
        $model = $this->getModel();
        $return = $model->getMap($pks);
 
	}

Then in my order model I've added this:
	public function getMap($pks)
	{
	
		// perform whatever you want on each item checked in the list
		$idList = implode($pks,',');
		
		// Get a db connection.
		$db = JFactory::getDbo();
		 
		// Create a new query object.
		$query = $db->getQuery(true);
		 
		// Select all records from the user profile table where key begins with "custom.".
		// Order it by the ordering field.
		$query->select(array('address', 'zip_code', 'city'));
		$query->from('#__orders');
		$query->where('id IN ('.$idList.')');
		$query->order('zip_code ASC');
		 
		// Reset the query using our newly populated query object.
		$db->setQuery($query);
		 
		// Load the results as a list of stdClass objects.
		$results = $db->loadObjectList();
		
		// create the addresslist
		foreach ($results as $item) { 
			
			if ($item === end($results)) {
				$to = "";
			} else {
				$to = "+to:";
			}
        
			$adrList .= $item->address . "," . $item->zip_code . "," . $item->city . $to;
		}
		
		$startAdr = "Denmark"; // replace with real start address
		
		// some work needs to be done here, to send this link to a new window, and return to view
		echo '<div style="text-align:center;"><a target="_blank" href="https://maps.google.com/maps?saddr='.$startAdr.'&daddr='.$adrList.'">Google Map Route</a></div>';
		
		return true;
	
	}

This returns the data of my selected items.

The link is created but not opened in a new window automatically.
I'm stuck on how to do this. Any help is appreciated.
Last Edit: 16 Jul 2013 15:50 by dyvel. Reason: Updatet with a price offer
The administrator has disabled public write access.

$20 for help: toolbar button to open new window 16 Jul 2013 15:52 #10478

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
I have updated my thread - I'd like to offer $20 for help on how to have my toolbar button stay on the current view, and open the link in a new window. As I wrote, the link is generated by the code to form a correct Google Map link.
The administrator has disabled public write access.

$20 for help: toolbar button to open new window 17 Jul 2013 05:24 #10484

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
This one might help - i wrote it a while back but most should still be relevant to current builds
www.j-cook.net/index.php/forum/design-yo...tart=0&start=15#4467

if that doesnt work let me know and i will try to assist
Last Edit: 17 Jul 2013 05:25 by BTB300.
The administrator has disabled public write access.

$20 for help: toolbar button to open new window 17 Jul 2013 05:29 #10485

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hi There dyvel
Just noticed something..
// Map
JToolBarHelper::customX('orders.getMap', 'map', 'map', "Google Map");

perhaps your issue is customX just use custom
// Map
JToolBarHelper::custom('orders.getMap', 'map', 'map', "Google Map");
Last Edit: 17 Jul 2013 05:30 by BTB300.
The administrator has disabled public write access.

$20 for help: toolbar button to open new window 17 Jul 2013 09:14 #10488

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
Hi

I actually had a look at your article, but I don't see the "missing link" to how I can use it it my case. As explained, I'm trying to make my toolbar button open up a google map based on my selected items. Currently the button opens up a new view with the link to google map, but that's not an elegant way of doing things.
The administrator has disabled public write access.

$20 for help: toolbar button to open new window 17 Jul 2013 11:43 #10492

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Are you using an existing button such as save close.... or creating a custom button?
I know you said custom but just checking...
Check the redirect i think in the current build you can use "stay" instead of the redirect

so do you want a modal popup or display on the layout itself

you have some options on the link to foreign in properties such as _modal, _self, _parent
and you can specify in the dom tags a url in place of where link will lead to (sorry cant remember off the top of my head) but someone did ask about redirecting to external urls perhaps you could use this somehow

Just throwing out some ideas
perhaps create a link to foreign use the modal, self or whatever and then make the linked field a button using css button class
Last Edit: 17 Jul 2013 12:04 by BTB300.
The administrator has disabled public write access.

$20 for help: toolbar button to open new window 17 Jul 2013 13:30 #10493

  • dyvel
  • dyvel's Avatar
  • Offline
  • Elite Member
  • Posts: 200
  • Thank you received: 11
  • Karma: 10
I've created a custom button.
The component is about 6 months old, so not the latest build. 2.0 I think.

Currently the button calls the function that builds the link based on the selections and displays that on a somewhat blank view.
Instead of the blank view with the link to Google Maps, it should just call the function and open the created link in a new window (not modal window).

Will research the redirect to external url.
The administrator has disabled public write access.

$20 for help: toolbar button to open new window 17 Jul 2013 15:54 #10498

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Found itadmin wrote:
Here the solution

STATIC
<?php echo JDom::_('html.fly', array(
'href' => 'www.google.com',  	//HERE
'dataKey' => 'link',
'dataObject' => $this->booksitem
));
?>

DYNAMIC
<?php echo JDom::_('html.fly', array(
'href' => $this->booksitem->link,  	//HERE
'dataKey' => 'link',
'dataObject' => $this->booksitem
));
?>
The administrator has disabled public write access.
The following user(s) said Thank You: admin
Time to create page: 0.079 seconds

Get Started