https://antibiotiqueaugmentin.com/surdosage-augmentin-bebe/
× Welcome to the ToolsJX forum!


Deactivate link if URL column value is empty

  • elmanchy
  • elmanchy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 6 months ago #2805

Hi
I wonder if there is any way not to link the empty URLs.
I mean, in "Links:" I have a Link for Column: 'Names', and Link Column: 'some URLs'
Not all the Names have URL, so, I don't want Names without URL to be linkable.
Currently my empty URLs are opening the root of my site.
Thanks

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

More
10 years 6 months ago #2807

Hi,

Unfortunately this is not possible without some hacking.

If you are familiar with PHP you can pimp the function createLink() in /components/com_grid/GridBuilder.php to return just $data if $link is empty.

We might also add this in future versions. Thanks for the idea.

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

  • elmanchy
  • elmanchy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 6 months ago #2812

Ok thank you very much, I'm trying but..
Please please help, I need to ad a couple of lines but I can't came up with them :ohmy: . This is my code:

function createLink($type, $link, $data, $customLink=""){
		//echo( "type:".$type." link:". $link." label:". $data." custom link:". $customLink."<br>");
		$output="";
		switch($type){
			case '0':{
				$output = $data;
			}break;
			case '1':{
				$output = '<a target="_blank" href="'.$link.'">'.$data.'</a>';
			}break;
			case '2':{
				$output = '<a target="_blank" href="?option=com_content&view=article&id='.$link.'">'.$data.'</a>';
			}break;
			case '3':{
				$link = str_replace('@ID', $link, $customLink);
				$output = '<a target="_blank" href="'.$link.'">'.$data.'</a>';
			}break;
			default:{
				$output = $data;
			}
		}
		return $output;
	}

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

More
10 years 5 months ago #2814

I would do something like this: B)

function createLink($type, $link, $data, $customLink=""){
		//echo( "type:".$type." link:". $link." label:". $data." custom link:". $customLink."<br>");
		$output="";

                if($link=="") return $data;
                      
		switch($type){
			case '0':{
				$output = $data;
			}break;
			case '1':{
				$output = '<a target="_blank" href="'.$link.'">'.$data.'</a>';
			}break;
			case '2':{
				$output = '<a target="_blank" href="?option=com_content&view=article&id='.$link.'">'.$data.'</a>';
			}break;
			case '3':{
				$link = str_replace('@ID', $link, $customLink);
				$output = '<a target="_blank" href="'.$link.'">'.$data.'</a>';
			}break;
			default:{
				$output = $data;
			}
		}
		return $output;
	}

The following user(s) said Thank You: elmanchy

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

  • elmanchy
  • elmanchy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
10 years 5 months ago #2836

Yes! thanks!!!!

It worked like a charm! :laugh:

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

Moderators: tomaz
Time to create page: 0.143 seconds

Contact Us

Contact us on Discord

Contact us on Facebook