Gossamer Forum
Home : Products : DBMan : Customization :

Linking outside of DBMan

Quote Reply
Linking outside of DBMan
Hello,

I would appreciate any help someone might provide for the following question.

Using User-friendlyHTML, we would like to link to a page outside of DBMan when a URL is provided in the the database entry. We would like to use an existing field 'Plan Name' for the link rather than displaying the URL as a separate entry in search results.

Will someone please provide feedback explaining how this can be done?

Code:
<A HREF="URL">Plan Name</A>
Where 'Plan Name' is another field in the database.


Best Regards,

Kim Lanners

Software Made Easy
http://sme-net.com
Quote Reply
Re: Linking outside of DBMan In reply to
If i understand the question correctly it would simply be a matter of linking from the field entered in your database.

If your database field "Plan Name" you could use:

<A HREF="$rec{Plan Name}">Plan Name</A>

Hope this is what you were looking for.


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Linking outside of DBMan In reply to
Actually, I think it would be

<a href="$rec{'URL'}">$rec{'Plan Name'}</a>



JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Linking outside of DBMan In reply to
JPDeni:

Sooooo glad to have you back ... see how much you were needed Smile

Glad you were here to catch that Smile

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Linking outside of DBMan In reply to
I'm glad to have my back back, too! Wink

Thanks much!!

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Linking outside of DBMan In reply to
Hi JPDeni!

Thank you for your reply! And, I too, am really glad to see you back. I do hope your back feels much better. Smile

Best Regards,

Kim Lanners

Best Regards,

Kim Lanners

Software Made Easy
http://sme-net.com
Quote Reply
Re: Linking outside of DBMan In reply to
Good Morning Lois,

In addition to thanking you for your prompt response to my question, I just wanted to say that I appreciate the way you are such a big presence on this list and ever so helpful! Smile



Best Regards,

Kim Lanners

Software Made Easy
http://sme-net.com
Quote Reply
Re: Linking outside of DBMan In reply to
Hi JPD, had to agree with the sentiment that it's good to have you back! A question remailns for me on the linking. Could you (or someone) please identify how to code for the hyperlink so as to allow for a link when there is a URL and prevent the <A HREF="http://"> from displaying if there is no URL added to the database? Not all records would have a URL at any given time.


Quote Reply
Re: Linking outside of DBMan In reply to
If you want to hide the field altogether you can use:

if ($rec{'URL'} {
print qq|
<a href="$rec{'URL'}">$rec{'Plan Name'}</a>
}

If you still wanted to plan name to appear even if there is no URL you can use:

if ($rec{'URL'} {
print qq|
<a href="$rec{'URL'}">$rec{'Plan Name'}</a>
}
else {
print qq| $rec{'Plan Name'}
)


There's also another trick JPDeni provided in the FAQ under "Fields" and "Syntax" called:
Using default value of http:// but no display if blank

which provides another alternative.

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Linking outside of DBMan In reply to
Thank you so much Lois! This is precisely what I need. I'll review JPD's fix in the resource center too. Thanks again.

Quote Reply
Re: Linking outside of DBMan In reply to
Finally was able to get the if statements to display content on the search results :-) however, I have one additional problem. In the config file, I am using
URL => [4, 'alpha', 40, 255, 1, 'http://', '^http://'],

which places a default http:// in the form so anyone would know the correct way to enter a URL in the db. The default is causing the Plan Name to still be "hyperlinked" with an incomplete URL when there isn't an address listed.

Any suggestions on resolving this so if a domain.com/page.html is not added to the record it will not cause a hyperlink to be added?

Thanks!

Quote Reply
Re: Linking outside of DBMan In reply to
Karen, you can do it one of two ways (or even a combination of the two! Smile).

If you have records in the database that have the http:// already in them, or you want to keep that in the database, use the following:

Code:

unless ($rec{'URL'} eq 'http://') {
print qq| etc |;
}
If you're starting with a brand new database and you would rather not save the http:// to the record, add the following code to db.cgi, sub parse_form:

Code:

if ($value eq "---") { next PAIR; }
if ($value eq "http://") { next PAIR; }
(exists $in{$name}) ?
($in{$name} .= "~~$value") : # If we have multiple select, then we tack on
($in{$name} = $value);
If you already have records in the database, but you would like for new records not to have the http:// saved to the record, add the change for sub parse_form and use the following in sub html_record:

Code:

if ($rec{'URL'} && ($rec{'URL'} ne 'http://')) {
print qq| etc |;
}
Lotsa choices!! Smile


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: Linking outside of DBMan In reply to
Hi Carol, the second option would probably work great. It is a new database and isn't live from a site anywhere yet. I'll give it a try in a short while - I'm having a difficult time in another area and trying my best to resolve it with FAQ's, resource center info, forums, etc. Trying to work with currency and quotes (foot & inch symbols) within the db itself. What fun for a novice :-)

I'll let you know which solution above works and of course, whether there were any problems with it. Thanks so much!

Quote Reply
Re: Linking outside of DBMan In reply to
Carol, the fix worked just as needed. We used the second option you suggested and *wink* once the URL was changed to not be a required field, everything is working as hoped for. Thanks!

Quote Reply
Re: Linking outside of DBMan In reply to
Excellent!!

If you have any more questions, don't hesitate to ask.

JPD
http://www.jpdeni.com/dbman/