I want Drupal comments to work like every other blogs in the fact non-users who are entering in their homepage can enter in "www.example.com" or "http://www.example.com" and they both work. Right now Drupal throws an error if it doesn't see http://

I want to pay someone to provide me a solution.

I'm not sure what is the best solution, whether it be a module, comments module patch, or something else. No matter what solution is decided on, I would like to see a patch for the core comments module come out of this.

Please email me at jluebke {at} xuru.com with a bid or more info.

Comments

vm’s picture

I don't see this on any of my sites. Whether I type in www.mysites.com or http://mysites.com or http://www.mysites.com

Have you made any alterations to your .htaccess file?

JeremyL’s picture

I don;t think you are understanding the problem as htaccess has nothing to do with comments and the homepage form field in the comments.

vm’s picture

you are correct, I did read the problem incorrectly.

frankdesign’s picture

Hi

I'm trying to figure out how to achieve this. I've found a way to do it at this website http://drupal.stackexchange.com/questions/1037/allow-comment-homepage-ur... but that involves hacking Drupal Core - which I obviously don't want to do. Can it be done with a function in template.php or how would I go about it. Any help would be much appreciated.

Thanks

F

archard’s picture

Anyone willing to throw out a bounty? I know I can do this via module.

frankdesign’s picture

Archard

I'd love to be able to throw you a few quid - but this job is already way over budget. I'm already out of pocket and there's no hope of getting any more money out of my client. If you can even point me in the right direction, I'd really appreciate it.

Thanks a mil

F

frankdesign’s picture

Ok, I've had a go at this but it's not working. My brain now hurts from all the searching and trying coding options. Here is the code I have come up with which I tried in my template.php file but nothing changed. Any ideas??

function mytheme_form_alter(&$form, &$form_state, $form_id)
{
  if($form_id == 'comment-form') // I haven't confirmed the $form_id, this is just an example
  {
    $form['#validate'][] = 'fifthprovince_custom_validation_function'; // this adds your validation function to the stack
  }
}

function fifthprovince_custom_validation_function($edit)
{
  if ($edit['homepage']) {
    if (strpos($edit['homepage'], "://") === FALSE) {
        $edit['homepage'] = "http://" . $edit['homepage'];
    }
    if (!valid_url($edit['homepage'], TRUE)) {
        form_set_error('homepage', t('The URL of your website is not valid. Remember that it must be fully qualified, i.e. of the form http://example.com/directory.'));
    }
  }
  return $edit;
}

I'd really appreciate any pointers.

Thanks a mil

F

criznach’s picture

You need to put that code in a module instead of template.php. hook_form_alter does not work in themes. It looks like you can just include your two functions and a simple .info file. Change mytheme_form_alter() to modulename_form_alter().

criznach’s picture

And... I'm not sure without trying it, but you probably need your custom validate function to run before the normal validation function. I believe what you have will run after.

frankdesign’s picture

Criznach

Thanks a mil for the pointers. I've created a module and put the validate function in it. I've also tried added several functions to try and call my validate function before the Core Comment Module calls its validate function - but no luck. Any ideas on how I can get my validate function to run first?

F

criznach’s picture

I don't have time to test this but you could try:

array_unshift($form['#validate'], 'fifthprovince_custom_validation_function');

or

$form['#validate'] = array_merge(array('fifthprovince_custom_validation_function'), $form['#validate']);
jghyde’s picture

I don't think it's if($form_id == 'comment-form'). Instead, try if($form_id == 'comment_form').

Joe Hyde
New Drupal Shop just opened in Texas: http://hydeinteractive.com/

Local News Platform Built on Drupal
http://sanangelolive.com/

jamesoakley’s picture

If that tweak on stackoverflow works for you, why not create an issue in the core issue queue, and propose the change as a patch? That way, others in the Drupal community can hone the modification until it gets to the point where it can be committed and become part of core.


This signature is currently blank