open a link new window inserted into the page LINKS_HOME

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
facos79
Veteran Member
Posts: 119
Joined: 2014-10-29 12:31

open a link new window inserted into the page LINKS_HOME

Post by facos79 » 2015-01-21 23:00

Hello, how do I open in a new window or a new tab link placed on the page LINKS_HOME?

Code: Select all

<?php
	/*
	 * You can add custom links in the home page by appending them here ...
	 * The format for each link is:*/
		$homeLinks[] = array(
			
			'url' => 'http://www.sitodiprova.net',
			'title' => 'Consulenza', 
			'description' => 'Consulente Tecnico Informatico',
			'groups' => array('all groups'), // groups allowed to see this link, use '*' if you want to show the link to all groups
			'grid_column_classes' => 'col-md-6 col-lg-4', // optional CSS classes to apply to link block. See: http://getbootstrap.com/css/#grid
			'panel_classes' => 'panel-danger', // optional CSS classes to apply to panel. See: http://getbootstrap.com/components/#panels
			'link_classes' => 'btn-danger', // optional CSS classes to apply to link. See: http://getbootstrap.com/css/#buttons
			'icon' => '/contratti-assistenza/ceo.png' // optional icon to use with the link
		);

Grazie per l'aiuto.

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 356
Joined: 2013-03-21 04:37

Re: open a link new window inserted into the page LINKS_HOME

Post by peebee » 2015-01-22 07:21

Insert this element into your array and you should be right. Works for me:

'target' => '_blank',

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 356
Joined: 2013-03-21 04:37

Re: open a link new window inserted into the page LINKS_HOME

Post by peebee » 2015-01-23 00:33

Edit to above. Sorry, just revisited this and see I forgot to mention you have to add the 'target' element to your generated home.php file

Find this code in home.php (around Line 71):

Code: Select all

<?php
		/* custom home links, as defined in "hooks/links-home.php" */
		if(is_array($homeLinks)){
			$memberInfo = getMemberInfo();
			foreach($homeLinks as $link){
				if(!isset($link['url']) || !isset($link['title'])) continue;
and replace with this:

Code: Select all

<?php
		/* custom home links, as defined in "hooks/links-home.php" */
		if(is_array($homeLinks)){
			$memberInfo = getMemberInfo();
			foreach($homeLinks as $link){
				if(!isset($link['url']) || !isset($link['title']) || !isset($link['target'])) continue;
Same process applies to nav-links. See here: http://forums.appgini.com/phpbb/viewtop ... rget#p3524

facos79
Veteran Member
Posts: 119
Joined: 2014-10-29 12:31

Re: open a link new window inserted into the page LINKS_HOME

Post by facos79 » 2015-01-23 11:38

Grazie ;)

lexena
Posts: 2
Joined: 2015-12-23 17:53

Re: open a link new window inserted into the page LINKS_HOME

Post by lexena » 2015-12-23 20:03

peebee wrote:Edit to above. Sorry, just revisited this and see I forgot to mention you have to add the 'target' element to your generated home.php file

Find this code in home.php (around Line 71):

Code: Select all

<?php
		/* custom home links, as defined in "hooks/links-home.php" */
		if(is_array($homeLinks)){
			$memberInfo = getMemberInfo();
			foreach($homeLinks as $link){
				if(!isset($link['url']) || !isset($link['title'])) continue;
and replace with this:

Code: Select all

<?php
		/* custom home links, as defined in "hooks/links-home.php" */
		if(is_array($homeLinks)){
			$memberInfo = getMemberInfo();
			foreach($homeLinks as $link){
				if(!isset($link['url']) || !isset($link['title']) || !isset($link['target'])) continue;
Same process applies to nav-links. See here: http://forums.appgini.com/phpbb/viewtop ... rget#p3524
Hi, I added the 'target' => '_blank', line to my links-home.php page and checked the home.php page for the code shown above but didn't find it. Is this because I am usinig the latest version of AppGini 5.50?? Please advise. I do know some PHP so I get I just need to know where it is located.

Thanks!
Lexe
Regards,
Lexe
Using AppGini Pro 5.50

lexena
Posts: 2
Joined: 2015-12-23 17:53

Re: open a link new window inserted into the page LINKS_HOME

Post by lexena » 2015-12-23 22:16

I found one more Caveat....
In incCommon.php, add target="<?php echo $link['target']; ?> to line 1222. Please below:
BEFORE:

Code: Select all

<a class="btn btn-block btn-lg <?php echo $link['link_classes']; ?>" title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", htmlspecialchars(strip_tags($link['description']))); ?>" <a href="<?php echo $link['url']; ?> &nbsp; target="<?php echo $link['target']; ?>"><?php echo ($link['icon'] ? '<img src="' . $link['icon'] . '">' : ''); ?><strong><?php echo $link['title']; ?></strong></a>
AFTER CHANGE:

Code: Select all

<a class="btn btn-block btn-lg <?php echo $link['link_classes']; ?>" target="<?php echo $link['target']; ?> title="<?php echo preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", htmlspecialchars(strip_tags($link['description']))); ?>" href="<?php echo $link['url']; ?>"><?php echo ($link['icon'] ? '<img src="' . $link['icon'] . '">' : ''); ?><strong><?php echo $link['title']; ?></strong></a>
Regards,
Lexe
Using AppGini Pro 5.50

gofigure
Posts: 5
Joined: 2015-12-10 13:28

Re: open a link new window inserted into the page LINKS_HOME

Post by gofigure » 2016-04-17 01:01

Ok so I cannot find the specified code in home.php or the other code in inCommon.php either. Has this changed with the latest release?

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 356
Joined: 2013-03-21 04:37

Re: open a link new window inserted into the page LINKS_HOME

Post by peebee » 2016-04-17 23:33

Code has changed for V5.50

Look in incCommon.php around line 1091 and 1218 and you will see this:

Code: Select all

if(!isset($link['url']) || !isset($link['title'])) continue;
change to this:

Code: Select all

if(!isset($link['url']) || !isset($link['title']) || !isset($link['target'])) continue;
The first instance is for Navigation links, second is for Home links.

I haven't actually tried it but that should do the job I think.

Post Reply