Weird results when building variable

I hope someone can shed some light on this, because it is driving me crazy:

My database returns two fields, {cb_name} and {cb_url}. The first contains a name of a company, the second the URL to their website.

I now build that into a string for a web link to be displayed in a grid. I do this on the onrecord event:

{fld_weblink} = ‘<a href="’.{cb_url}.’" target="_blank">’.{cb_name}.’</a>’;

assume
{cb_name} = ‘My Company’;
{cb_url} = "http://www.mycompany.com’;

When {fld_weblink} is displayed in the grid the url now appears as

http://localhost/www.mycompany.com

Where is it getting “localhost” from? How can I get around this to ensure the integrity of variably is maintained?

Thanks

Re: Weird results when building variable

This could be related to a security in the browser when dealing with local files. I always get ‘fakepath’ in chrome, what is your browser?
http://www.tarikguney.com/note/the-mystery-of-fakepath-of-upload-control/

Regards,
Scott.

Re: Weird results when building variable

I know you are not specifying a filename, but Perhaps something that SC/browser is doing to ‘assume’ the hostname in URL’s?

Regards,
Scott.

Re: Weird results when building variable

This could also be a server configuration? Are you using XAMP/WAMP?

google: url changes localhost

Regards,
Scott.

Re: Weird results when building variable

Guys,
I get the same result in all three major browsers. My local server is linux (Arch server). Putting the project on a virtual host (linux/ apache/ php) also gives the same outcomes.

Re Scott’s suggestion about including the file name, index.html or something similar, it has no effect.

OK, so the only alternative seem to be to use the URL field type. However, this give an awful presentation.

Any suggestions how else I might get a nice presentable website link field into a grid?

Thanks

Re: Weird results when building variable

I get the same result on our web server, i.e., not localhost.

Re: Weird results when building variable

I suspect you’re right. Just tried Konqueror and got the same thing.

When I run it on our web server the link is presented as

http://www.ourdomain.com/www.cb_url.com

when cb_url is http://www/cb_url.com

Kludged: Weird results when building variable

I found a work around;

assign the URL to php variable, then build the grid field;

$k = {cb_url};
{fld_weblink} = ‘<a href="’.$k.’" target="_blank">’.{cb_name}.’</a>’;

I have no idea why that should work when this

{fld_weblink} = ‘<a href="’.{cb_url}.’" target="_blank">’.{cb_name}.’</a>’;

doesn’t.

Re: Weird results when building variable

Sounds like SC is playing big brother when it comes to their internal macro vars. When you assign it to a PHP var, it leaves it alone.

Regards,
Scott.

Re: Weird results when building variable

Looking back on my notes I see I’ve had this before, i.e. having to assign the values to a php variable first and then to the SC variable so that SC didn’t corrupt things during code generation.

Cheers