PDA

View Full Version : Fields not required


Merridy
12-25-2006, 10:53 PM
I've searched for this problem, but can't find an answer applicable to version 2.0.01. With the URL field I've set it as "not required" in the manage field admin panel. However when I try to submit a link it asks for a valid URL. Not everyone who used my directory will have a URL. How can I fix this.

Dave Baker
12-25-2006, 11:44 PM
Hello Merridy,
***Open suggest-link.php and find code***

/** check URL **/
$link['url'] = $_POST['url'];
if (!empty($_POST['url']) && ('url' == $field_name))
{
$link['url'] = 0!==strpos($_POST['url'],"htt") ? "http://".$_POST['url'] : $_POST['url'];
}
if ((!$_POST['url'] || !valid_url($link['url'])) && ('url' == $field_name))
{
$error = true;
$msg .= "<li>{$gDirLang['error_url']}</li>";
}
elseif (('url' == $field_name) && valid_url($_POST['url']) && $_POST['url'])

***Replace with the following code***

/** check URL **/
$link['url'] = $_POST['url'];
if (!empty($_POST['url']) && ('url' == $field_name))
{
$link['url'] = 0!==strpos($_POST['url'],"htt") ? "http://".$_POST['url'] : $_POST['url'];
}
if (((!$_POST['url'] || !valid_url($link['url'])) && ('url' == $field_name)) && $value['required'])
{
$error = true;
$msg .= "<li>{$gDirLang['error_url']}</li>";
}
elseif (('url' == $field_name) && valid_url($_POST['url']) && $_POST['url'])

***Save file***

bunny
12-25-2006, 11:56 PM
Hello Merridy,
***Open suggest-link.php and find code***

/** check URL **/
$link['url'] = $_POST['url'];
if (!empty($_POST['url']) && ('url' == $field_name))
{
$link['url'] = 0!==strpos($_POST['url'],"htt") ? "http://".$_POST['url'] : $_POST['url'];
}
if ((!$_POST['url'] || !valid_url($link['url'])) && ('url' == $field_name))
{
$error = true;
$msg .= "<li>{$gDirLang['error_url']}</li>";
}
elseif (('url' == $field_name) && valid_url($_POST['url']) && $_POST['url'])

***Replace with the following code***

/** check URL **/
$link['url'] = $_POST['url'];
if (!empty($_POST['url']) && ('url' == $field_name))
{
$link['url'] = 0!==strpos($_POST['url'],"htt") ? "http://".$_POST['url'] : $_POST['url'];
}
if ((!$_POST['url'] || !valid_url($link['url'] ) && ('url' == $field_name) && $value['required']))
{
$error = true;
$msg .= "<li>{$gDirLang['error_url']}</li>";
}
elseif (('url' == $field_name) && valid_url($_POST['url']) && $_POST['url'] && $value['required'])

***Save file***

Is that a patch ? Cause i just downloaded 2.01 version do i need to use the patch also that exists in the download section?

Merridy
12-26-2006, 12:42 AM
Thanks Dave,
Works great! Poses another question though. Will I have to make changes to edit link and upgrade link as well so that the editor isn't asked to add a URL there as well? If so, what are those changes? Have managed to make minor changes to pages myself, but I'm not really up to doing the big stuff.

Also, I've now found there is a problem with email field. I've checked that it IS REQUIRED, but I've tried leaving it blank and it allows the link to be submitted. Is there a problem in that area if the admin panel? I installed all the patches as far as I know.

Dave Baker
12-26-2006, 12:48 AM
@bunny Version Pro v2.0.01 includes Patch 2.0.01, but this addition in the patch is absent.

bunny
12-26-2006, 01:27 AM
Oh k, so cool i got patched directory :)

Dave Baker
12-26-2006, 01:33 AM
@Merridy
***Open edit-link.php and find code***

/** check URL **/
if (!$link['url'])
{
$error = true;
$msg .= "<li>{$gDirLang['error_url']}</li>";
}

***Replace with the following code***

/** check URL **/
if (!$link['url'] && $fields['1']['required'])
{
$error = true;
$msg .= "<li>{$gDirLang['error_url']}</li>";
}

***Save file***
Editor doesn't change data about link with " Upgrade Listing " action, on this there isn't necessity to make changes with code.
If you use editor functionality, all data on the user and his Email available in a database (he specified it at registration), for this reason we ignore field Email.

Merridy
12-26-2006, 05:07 AM
Thanks again Dave,
I realised after I posted the last message that I was logged in as editor and that's why my email wasn't required. Ooops.
The URL thing works great now.........at least it does in the front end. When I try to add links through the admin panel it still asks me for a valid URL! I guess I can do them through the front end for now.

Dave Baker
12-29-2006, 11:29 PM
In order to correct it ***open admin/suggest-link.php and find code (around line 141)***

if (!$_POST['url'] || ($_POST['url'] == 'http://'))
{
$error = true;
$msg = $gDirLang['error_url'];
}

***Replace with following code***

if ((!$_POST['url'] || ($_POST['url'] == 'http://')) && $fields['1']['required'])
{
$error = true;
$msg = $gDirLang['error_url'];
}

***Save file***

Merridy
12-30-2006, 12:36 AM
Great! Thanks!

Dave Baker
01-06-2007, 07:18 PM
You're welcome Merridy!

dpeterson
01-16-2007, 10:35 PM
That is a great fix Dave. Is there anyway to make the names non-clickable when there isn't any url to go to? I click on a name with no url and it takes me to the category root. From there I have to click back up to the sub-category that I was browsing.

Dave Baker
01-16-2007, 11:30 PM
I've slightly corrected code in this post (changed a condition to better variant):
http://www.esyndicat.com/forum/showpost.php?p=54653&postcount=2
Is there anyway to make the names non-clickable when there isn't any url to go to?
***Open index.php and find code***

/** get links for this category **/
$featured_top = ($gDirConfig['order_featured'] && $gDirConfig['featured_links']) ? TRUE : FALSE;
$sponsored_top = ($gDirConfig['sponsored_top'] && $gDirConfig['sponsored_links']) ? TRUE : FALSE;
$links =& $gDirDb->getLinksByCategory($category['id'], $start, $gDirConfig['num_index_links'], $featured_top, $sponsored_top, $gDirEditor['id']);

***Below this code add***

foreach ($links as $key => $value)
{
if (!valid_url($value['url']))
{
$links[$key]['domain'] = 0;
}
}

***Save file***
***Open templates/yourTemplate/link-display.tpl and find code***

<div class="title">{if $link.crossed}@{/if} <a href="{$link.url}" class="title" id="l{$link.id}" {if $config.new_window}target="_blank"{/if}>{if $config.html_tags}{$link.title}{else}{text_html aText=$link.title}{/if}</a>

***Replace with the following code***

{if $link.domain}
<div class="title">{if $link.crossed}@{/if} <a href="{$link.url}" class="title" id="l{$link.id}" {if $config.new_window}target="_blank"{/if}>{if $config.html_tags}{$link.title}{else}{text_html aText=$link.title}{/if}</a>
{else}
<div class="title">{if $link.crossed}@{/if} {if $config.html_tags}{$link.title}{else}{text_html aText=$link.title}{/if}
{/if}

***Save file***

dpeterson
01-16-2007, 11:47 PM
Thank you, It works great!!!

Dave Baker
01-16-2007, 11:56 PM
You're welcome dpeterson!