Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    General discussion (Moderator: korb)    Topic: Change the url input field to a Title input field
Pages: [1]   Go Down
  Print  
Author Topic: Change the url input field to a Title input field  (Read 7908 times)
0 Members and 1 Guest are viewing this topic.
poffen
Newbie
*

Karma: 0
Offline Offline

Posts: 27


« on: December 17, 2008, 21:03:34 »

Hi,

I've integrated the Jcomments with Sobi2 and it works really nice  Smiley This is also the only commenting system which integrates fully with Sobi2!

However, I need an option to include a title with each comment, whereas I don't need the url option that's already there. My question is therefore if it's possible to change the url input field to a title input field, without too much recoding of the component. If this could be done easily (and safely), what files (except template) should I look for?

I need the title option badly...

Sincerely,

Poffen

Logged
smart
Administrator
Hero Member
*****

Karma: 88
Offline Offline

Gender: Male
Posts: 1867



WWW
« Reply #1 on: December 17, 2008, 21:51:38 »

You can add this field to form in /com_jcomments/tpl/default/tpl_form.php, then open jcomments.ajax.php and find line:

Code: (php)
$comment->object_group = $values['object_group'];

and add after it following code:

Code: (php)
$comment->title = isset($values['title']) ? $values['title'] : '';

And at last you must add displaying this field in /com_jcomments/tpl/default/tpl_comment.php

Try this...
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
poffen
Newbie
*

Karma: 0
Offline Offline

Posts: 27


« Reply #2 on: December 18, 2008, 05:08:03 »

Hi smart,

That worked as a dream!  Grin  Grin  Grin I reallllllly appreciate your quick response and help on this!!!

I've attached an image to show you how the title option renders...

Once again, Thanks alot!  Grin

Poffen
......................
[Edit]
I should add, of course, that I didn't have to remove the url field...


* title-display.png (21.67 KB, 701x337 - viewed 575 times.)
« Last Edit: December 18, 2008, 05:56:53 by poffen » Logged
smart
Administrator
Hero Member
*****

Karma: 88
Offline Offline

Gender: Male
Posts: 1867



WWW
« Reply #3 on: December 18, 2008, 12:41:07 »

I think in next version this feature can be added to distributive... as optional...
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
poffen
Newbie
*

Karma: 0
Offline Offline

Posts: 27


« Reply #4 on: December 18, 2008, 16:04:57 »

... that's a good idea.  Wink I'm quite sure that will increase the usability of the component ...

Once again, thanks... Smiley

Poffen
Logged
giuse
Newbie
*

Karma: 0
Offline Offline

Posts: 14


« Reply #5 on: December 31, 2008, 07:32:37 »

You can add this field to form in /com_jcomments/tpl/default/tpl_form.php, then open jcomments.ajax.php and find line:

Code: (php)
$comment->object_group = $values['object_group'];

and add after it following code:

Code: (php)
$comment->title = isset($values['title']) ? $values['title'] : '';

And at last you must add displaying this field in /com_jcomments/tpl/default/tpl_comment.php

Try this...
Hi, probably I am missing something: I added something in tpl_form.php, added the line in jcomments.ajax.php and added the following in the tpl_comment.php:
Code:
<p><span class="comment-title" id="comment-title-<?php echo $comment->title?>"><font color=black><strong><u><?php echo $comment->title?></u></strong></font></span></p>
Now I see the title box in the form but whatever I enter, it is not stored. Infact in the jcomment.ajax.php file I changed to

Code:
$comment->title = isset($values['title']) ? $values['title'] : 'nothing';

and always 'nothing' is stored as title, so isset returns always 'false'.... What am I missing?
The strange thing is that also the website field seems not to work: anything I write is not stored in the DB. The other fields (comment body, date, time, rating) work fine  Sad .
Thanks

Giuse
Logged
giuse
Newbie
*

Karma: 0
Offline Offline

Posts: 14


« Reply #6 on: January 02, 2009, 16:55:17 »

After several attempts (I am not a PHP programmer..) I managed to make it work for the title. I also found that the translation strings for the title field must be put in the language folders.

Still, the website field does not work here (whatever I write, it is not stored...)  Sad
Cheers

Giuse
Logged
poffen
Newbie
*

Karma: 0
Offline Offline

Posts: 27


« Reply #7 on: January 02, 2009, 22:57:29 »

Hi giuse,

Here are the steps I took to implement the title option. I did this on version 2.0.0.14, and I can not guarantee my hack will work for other versions. Note, this will give the look and feel that I have in my installation...

First, Backup, backup...

1) In /com_jcomments/tpl/default/tpl_comment.php

insert this:

Code:
<?php
/* Added title */
?>

<span class="comment-title"><?php echo $comment->title?></span><br /><br style="padding-bottom:8px;" />

after  this line:
Code:
<a class="comment-anchor" href="<?php echo $thisurl?>#comment-<?php echo $comment->id?>" id="comment-<?php echo $comment->id?>">#<?php echo $comment_number?></a>

2) In /com_jcomments/tpl/default/tpl_form.php

Insert this:

Code:
/* Added title to the form */
?>
<p>
<input id="comments-form-title" type="text" name="title" value="" maxlength="<?php echo $this->getVar('comment-name-maxlength');?>" size="22" tabindex="1" />
<label for="comments-form-title"><?php echo JText::_('FORM_TITLE'); ?></label>
</p>
<?php

after this line:

Code:
<div class="comments-policy"><?php echo $this->getVar'comments-policy' ); ?></div>
<?php

Note that the title field will be the first input field in the form. You should therefore adjust the tabindex value of the form objects all along, starting with tabindex="1" for the title input field (there should be 9 of them now).

3) In /com_jcomments/jcomments.ajax

Insert this:

Code:
$comment->title = isset($values['title']) ? $values['title'] : '';

after this line:

Code:
$comment->object_group = $values['object_group'];

4) In order to have a layout like the one I have you need to make some changes to the css file (/com_jcomments/tpl/default/style.css)

To make it simple, I suggest you replace the whole block of code, although there are only a few changes to the css.

Find and replace this block of code:

Code:
#comments .avatar-indent {padding-left: 40px;}

#comments a.comment-anchor,
#comments a.comment-anchor:active,
#comments a.comment-anchor:focus,
#comments a.comment-anchor:hover {color: #777; background-color: inherit; text-decoration: none; border: none;}

#comments span.comment-author,
#comments a.author-homepage {color: #3c452d;background-color: inherit;font: bold 1em Verdana, Arial, Sans-Serif;margin: 0;padding: 0;}
#comments a.author-homepage {text-decoration: none; border-bottom: 1px dotted #3c452d;}

/*avatar*/
#comments .comment-avatar img {width: 32px; height: 32px;}

/*date and time*/
#comments span.comment-date {font-size: 10px;color: #999;margin: 0;padding: 0 0 0 12px;background: url(images/jc_date.gif) no-repeat center left;}
#comments span.comment-body {color: #777;background-color: inherit;display: block;margin: 0;padding: 2px 0;}

/* Quote, Code and Hidden block styles */
#comments span.quote, #comments blockquote {margin: 5px 0 5px 10px; display: block; clear: both; }
#comments blockquote, #comments span.hidden {
color: #849B9F;
background-color: inherit;
text-align: left;
padding: 8px;
border: 1px dashed #849B9F;
margin-bottom: 8px;

with this code:

Code:
#comments .avatar-indent {padding-left: 45px;}

#comments a.comment-anchor,
#comments a.comment-anchor:active,
#comments a.comment-anchor:focus,
#comments a.comment-anchor:hover {color: #777; background-color: inherit; text-decoration: none; border: none;}

#comments span.comment-title {color: #b01625;background-color: inherit;font: bold 1.2em Verdana, Arial, Sans-Serif;margin: 0px;padding: 0px;}

#comments span.comment-author {font-size: 11px;color: #807e7e;margin: 0px 8px 0px 10px;padding: 0;}
#comments a.author-homepage {color: #807e7e;background-color: inherit;font: normal 11px Verdana, Arial, Sans-Serif;margin: 0px 8px 3px 10px;padding: 0;}
#comments a.author-homepage {text-decoration: none; border-bottom: 1px dotted #3c452d;}

/*avatar*/
#comments .comment-avatar img {width: 32px; height: 32px;}

/*date and time*/
#comments span.comment-date {font-size: 10px;color: #807e7e;margin: 0;padding: 0 0 0 13px;background: url(images/jc_date.gif) no-repeat center left;}
#comments span.comment-body {color: #777;background-color: inherit;display: block;margin: 0;padding: 10px 0; font-size:1.15em; line-height:1.15em;}

/* Quote, Code and Hidden block styles */
#comments span.quote, #comments blockquote {font-size: 11px;margin: 5px 0 5px 10px; display: block; clear: both; }
#comments blockquote, #comments span.hidden {
color: #849B9F;
background-color: inherit;
text-align: left;
font-family: Verdana, Arial, Sans-Serif;
padding: 8px;
border: 1px dashed #849B9F;
margin-bottom: 8px;
font-size:0.9em;
line-height:1.08em;

5) And finally, add this definition to all language files you're using (translate if you have to):

Code:
FORM_TITLE=Title

That's it!

Hope this helps...

Regards Poffen
Logged
giuse
Newbie
*

Karma: 0
Offline Offline

Posts: 14


« Reply #8 on: January 03, 2009, 00:18:49 »

Thanks for your very detailed instructions!! I hope next version will incorporate the title option.
Happy New Year  Wink

Giuse
Logged
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    General discussion (Moderator: korb)    Topic: Change the url input field to a Title input field
 
Jump to: