Remove required "subject" from comments module

peh

Joined: 2002-11-24
Posts: 15
Posted: Sun, 2005-10-02 12:49

Anyone knows how to get rid of the mandatory "subject" when entering
a comment?

I would like users to be able to put in a comment, without bothering
finding a subject... if they want to say "Nice picture"... I really dont
need to enforce a subject to be entered...

Regards,
Paul.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2005-10-02 15:30

I don't know what to change, but it looks like you'd edit this file:
/modules/comment/templates/AddComment.tpl before you edit it copy it to /modules/comment/templates/local/AddComment.tpl and edit that new copy.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
hubear

Joined: 2005-10-05
Posts: 6
Posted: Wed, 2005-10-05 15:46

Any solution for this problem? Anyone?

Thanks!

 
alesh

Joined: 2005-10-30
Posts: 1
Posted: Sun, 2005-10-30 12:01

I'm not sure... i see

    {if isset($form.error.subject.missing)}
    <div class="giError">
      {g->text text="You must enter a subject!"}
    </div>
    {/if}

in that file, but it seems that modifying that gets rid of the error message, not the necessity of a comment subject. any other suggestions?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sun, 2005-10-30 17:00

Here's what I did to get this hack to work.

NOTE: this is a hack, upon upgrading or reinstalling of Gallery some of your changes WILL be overwritten

1) Edit /modules/comment/AddComment.inc and remove the two places this code exists in the file

	    if (empty($form['subject'])) {
		$error[] = 'form[error][subject][missing]';
	    }

2) Edit /modules/comment/templates/AddComment.tpl and copy it to /modules/comment/templates/local/AddComment.tpl (this way at least some of your changes are not ovewritten on an upgrade). Remove this code:

{if isset($form.error.subject.missing)}
    <div class="giError">
      {g->text text="You must enter a subject!"}
    </div>
    {/if}

You'll probably also want to change this code

   <h4>
      {g->text text="Subject"}
      <span class="giSubtitle"> {g->text text="(required)"} </span>
    </h4>

To this

   <h4>
      {g->text text="Subject"}
    </h4>

___________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
Ebonlupus

Joined: 2005-05-17
Posts: 11
Posted: Fri, 2006-04-14 14:11

I find the inclusion of a comment subject somewhat redundant and annoying. Especially since it's a required field. I'd really like to make this subject field go away forever... or make it an optional field, at least.

Thanks for the mods, nivekiam.

 
kylehase
kylehase's picture

Joined: 2005-09-15
Posts: 38
Posted: Mon, 2006-07-24 03:36

Don't forget to also do the same for /modules/comment/EditComment.inc and /modules/comment/templates/local/EditComment.tpl or the users will have to add a subject if they want to edit their comments later.

 
skunker

Joined: 2005-02-04
Posts: 344
Posted: Wed, 2007-08-22 16:48

Can someone please write me a hack that is using the latest version of Gallery2? I ask because the above steps are not doable with the new comments module since the above code is not available in this new module. Thanks....

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Wed, 2007-08-22 17:40

If you are just looking to make the subject not required, then that hack is no longer needed. The code was changed on 7/31/2006 to not require the subject.

I verified on my gallery install, currently running 2.2.1 and double checked the code for 2.2.2.

Just reply if you need further assistance.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
skunker

Joined: 2005-02-04
Posts: 344
Posted: Wed, 2007-08-22 17:45

thanks nivekiam! If it's not required, then how do I remove the "subject" field all together from appearing ? Or, can I turn it off from the SITE ADMIN?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Wed, 2007-08-22 18:56

Edit /modules/comment/templates/AddComment.tpl and copy it to /modules/comment/templates/local/AddComment.tpl (this way at your changes are not ovewritten on an upgrade). I've attached the current AddComment.tpl that's included with Gallery 2.2.2 with the changes I show below. If you download the file, just rename it to AddComment.tpl and put in that local directory I mention above.

Make the following changes if you want to do this manually.

Line 16

    <h3> {$form.subject|markup} </h3>

Lines 44 through 57

    <h4> {g->text text="Subject"} </h4>

    {include file="gallery:modules/core/templates/MarkupBar.tpl" viewL10domain="modules_core"
	     element="subject" firstMarkupBar=true}

    <input type="text" id="subject" size="60" class="gcBackground1"
	   name="{g->formVar var="form[subject]"}" value="{$form.subject}"
	   onfocus="this.className=''" onblur="this.className='gcBackground1'"/>
    {if empty($inBlock)}
    <script type="text/javascript">
      document.getElementById('addCommentForm')['{g->formVar var="form[subject]"}'].focus();
    </script>
    {/if}

If you want to auto-focus to the Comment area like it was doing for the subject line then copy the code that's in red below to line 69, right after this bit of code:

    <textarea rows="15" cols="60" id="comment" class="gcBackground1"
       name="{g->formVar var="form[comment]"}"
       onfocus="this.className=''" onblur="this.className='gcBackground1'">{$form.comment}</textarea>
    {if empty($inBlock)}
    <script type="text/javascript">
      document.getElementById('addCommentForm')['{g->formVar var="form[comment]"}'].focus();
    </script>
    {/if}

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
skunker

Joined: 2005-02-04
Posts: 344
Posted: Wed, 2007-08-22 20:33

Thanks! I will try this....btw, what do you mean by "autofocus" ?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Wed, 2007-08-22 20:44

er, should have just said "focus", instead of "auto-focus". Sorry, been playing around with my camera a lot lately and have different terminology on my mind.

I mean when the page loads the focus of the text field (or textarea in this case). The comment page loads and the person can just start typing instead of clicking in the comment area first.

edit: here's a bit more info: http://apnasaathi.blogspot.com/2006/11/default-focus-on-page-load.html

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
muhanadu

Joined: 2008-05-12
Posts: 3
Posted: Mon, 2008-05-12 16:44

hi all ...
can any1 tell me how can i do that with the new version 2.2.4
thanks in advanced