View Full Version : Make URL field not required
DougM
09-29-2004, 01:08 AM
I would like to know if it is possible to allow links to be added without a valid URL. Currently this returns an error message.
In case you are curious... I plan to create a business directory where not all members will have websites. I would like to allow members to add links (or companies) with only an email or address field which I create through the custom fields feature. I will probably change "Links" to "Companies" in phrases to complete the transition.
Thanks.
Brian
09-29-2004, 09:10 PM
In your addlink.php file look for this code and remove it and that should do the trick.
if ($_POST['url'] == 'http://' OR !$_POST['url'] OR !$_POST['name'] OR !$_POST['description'])
{
eval('$errors[] = "' . fetch_phrase('adv_links_missingfiled', PHRASETYPEID_ERROR) . '";');
}
DougM
09-29-2004, 10:04 PM
Thanks Brian
Lionel
11-16-2004, 04:18 PM
Exactly what I came to look for. Now, which conditionals should I add so "view site" does not display in links options for those without url?
Brian
11-16-2004, 04:28 PM
Add this around the table row in your adv_links_linkbit template:
<if condition="$link['url']">
URL Table Row
</if>
Lionel
11-16-2004, 05:19 PM
<if condition="$links['url']"><tr><td align="$stylevar[left]" class="vbmenu_option"><a href="showlink.php?l=$link[linkid]" target="_blank">$vbphrase[view_site]</a></td>
</tr></if>
that does not display the sentence at all, even for the ones with url
Brian
11-16-2004, 05:41 PM
Sorry, change $links there to $link and that should work. :)
Lionel
11-16-2004, 05:43 PM
perfect, thank you sir.
DougM
12-19-2004, 06:02 AM
Well I started this but now I'm trying to use the conditionals which Lionel had success with. Lionel - I wonder if you had to do more tweaking than mentioned here? Here is my problem:
"http://" is shown by default in the URL field text box so I just delete it if the entry has no URL.
The trouble - "http://" reappears in the link details after it is saved. Something is adding it and I can't find it. Therefore the URL field is never empty and the "View Site" option is always present.
Any thoughts on how to prevent "http://" from being automatically entered here?
Thanks
--------------------------------------------
EDIT: Here's what I did after some fumbling around. Not sure of possible unintended consequences so tell me if I should put it back. Seems to work though.
Opened addlink.php and deleted: if ($urlcheck != 'http://' AND $urlcheck != 'https:/')
{
$_POST['url'] = 'http://' . $_POST['url'];
}
Lionel
03-16-2005, 08:11 AM
Help! I am having a hard time. I can get it to work only when I don't verify links. Otherwise it returns the error message in the page
The URL you entered is not valid. Please make sure that you have entered a valid URL.
but I want to verify links when there is one.
if (!$_POST['name'])
{
eval('$errors[] = "' . fetch_phrase('adv_links_missingfiled', PHRASETYPEID_ERROR) . '";');
}
// $urlcheck = substr(trim($_POST['url']), 0, 7);
// if ($urlcheck != 'http://' AND $urlcheck != 'https:/')
// {
// $_POST['url'] = 'http://' . $_POST['url'];
// }
if ($vba_options['links_verifynew'])
{
$geturl = @parse_url(trim($_POST['url']));
$host = $geturl['host'];
$path = $geturl['path'];
if(!@fsockopen($host, 80, $errno, $errstr, 20))
{
eval('$errors[] = "' . fetch_phrase('adv_links_invalid_url', PHRASETYPEID_ERROR) . '";');
}
}
Brian
03-16-2005, 09:24 AM
Replace this code:
$urlcheck = substr(trim($_POST['url']), 0, 6);
if (!in_array($urlcheck, array('http:/', 'https:', 'ftp://')))
{
$_POST['url'] = 'http://' . $_POST['url'];
}
if ($vba_options['links_verifynew'])
{
$geturl = @parse_url(trim($_POST['url']));
$host = $geturl['host'];
$path = $geturl['path'];
if(!@fsockopen($host, 80, $errno, $errstr, 20))
{
eval('$errors[] = "' . fetch_phrase('adv_links_invalid_url', PHRASETYPEID_ERROR) . '";');
}
}
With this:
if (trim($_POST['url']) AND $_POST['url'] != 'http://')
{
$urlcheck = substr(trim($_POST['url']), 0, 6);
if (!in_array($urlcheck, array('http:/', 'https:', 'ftp://')))
{
$_POST['url'] = 'http://' . $_POST['url'];
}
if ($vba_options['links_verifynew'])
{
$geturl = @parse_url(trim($_POST['url']));
$host = $geturl['host'];
$path = $geturl['path'];
if(!@fsockopen($host, 80, $errno, $errstr, 20))
{
eval('$errors[] = "' . fetch_phrase('adv_links_invalid_url', PHRASETYPEID_ERROR) . '";');
}
}
}
And that should do the trick.
Lionel
03-17-2005, 11:25 AM
URL check supposed to verify that site exists? Cause it is allowing any junks to be entered...
Brian
03-17-2005, 11:27 AM
If you have the option turned on, yes.
Lionel
03-17-2005, 11:29 AM
It's on and it is posting broken links
Brian
03-17-2005, 11:30 AM
Would you mind submitting a support ticket so I can have a look then?
FamilyCorner
11-25-2005, 02:01 PM
In your addlink.php file look for this code and remove it and that should do the trick.
if ($_POST['url'] == 'http://' OR !$_POST['url'] OR !$_POST['name'] OR !$_POST['description'])
{
eval('$errors[] = "' . fetch_phrase('adv_links_missingfiled', PHRASETYPEID_ERROR) . '";');
}
I did exactly what you said to do here but it had no affect whatsoever. Am I missing something?
Incidentally, I don't want urls AT ALL. I am using this to house the actual content, which are short tips and recipes. Therefore they don't need a url, the information the viewer needs will be right in the "site description".
Also, my code from addlink.php was not EXACTLY like what you have quoted to remove. Here's what mine originally looked like:
if ($_POST['url'] == 'http://' OR !$_POST['url'] OR !$_POST['name'] OR !$_POST['description'])
{
eval('$errors[] = "' . fetch_error('adv_links_missingfiled') . '";');
}
I just downloaded and installed this today, so it should be the most recent release.
FamilyCorner
11-25-2005, 02:40 PM
Ok I just read a little more carefully above and I have it working now, my apologies for jumping the gun.
However, is there a way to remove the url field from the submit a link form all together? It's working now where I can submit a link and REMOVE the http: from the url and it will submit, but I would like that field gone completely.
Also, I cannot add a link through the admin CP. Tells me there's a field missing when I leave out the url. :(
FamilyCorner
11-25-2005, 02:45 PM
However, is there a way to remove the url field from the submit a link form all together? It's working now where I can submit a link and REMOVE the http: from the url and it will submit, but I would like that field gone completely.
:eek:
Sorry, I seem to be answering my own questions here. I went into the template ADV_LINKS_ADD_EDIT and found the following, should I just remove it?
<fieldset class="fieldset"><legend>$vbphrase[url]</legend>
<div style="padding:$stylevar[formspacer]px">
$vbphrase[enter_url_for_website]<br />
<input type="text" class="bginput" name="url" value="<if condition="$show['editlink'] OR $errors">$linkurl<else />http://</if>" size="40" />
</div>
</fieldset>
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.