Page 1 of 1

How to fill in Comments "user" with customcontent_loginname? [solved]

Posted: Tue Dec 19, 2006 9:01 am
by nakuttaja
Hi!

How can I fill in the Comments "user"-field with customcontent_loginname? So the user wouldn't have an option to insert it's name but it being filled automatically. I have already made that "Add comment" is only available for logged in users.

Thanks, Nakuttaja

Re: How to fill in Comments "user" with customcontent_loginname?

Posted: Thu Dec 21, 2006 7:31 am
by nakuttaja
Sorry to bring this up, but I still haven't find the answer.

Re: How to fill in Comments "user" with customcontent_loginname?

Posted: Thu Dec 21, 2006 10:36 am
by tsw
hmm, havent checked the source one bit but I bet you could do it by inserting customcontent_loginname into the comments user field field value parameter and changing it to be type="hidden"

hope this helps

Re: How to fill in Comments "user" with customcontent_loginname?

Posted: Thu Dec 21, 2006 1:00 pm
by nakuttaja
tsw wrote: hmm, havent checked the source one bit but I bet you could do it by inserting customcontent_loginname into the comments user field field value parameter and changing it to be type="hidden"

hope this helps
In Comments Display Template there is just this:
{$yournametxt}

I looked those php-files but I don't really know anything about programming so it just confusing me  :-\

Re: How to fill in Comments "user" with customcontent_loginname?

Posted: Wed Dec 27, 2006 10:47 am
by nakuttaja
up.

There must be someone who has already made this kind of integration.  ???

Re: How to fill in Comments "user" with customcontent_loginname?

Posted: Tue Jan 02, 2007 3:26 pm
by cyberman
nakuttaja wrote: In Comments Display Template there is just this:
{$yournametxt}
That's only the text field, not the input field  :) ...

I'm not a coder for real but have you tried something like this?

Open action.default.php with your favourite editor, go to line 235

Code: Select all

	$this->smarty->assign_by_ref('inputyourname', 	$this->CreateInputText($id, 'author', $author, 50, 255));
and change it to

Code: Select all

	$this->smarty->assign_by_ref('inputyourname', 	$loginname);

Re: How to fill in Comments "user" with customcontent_loginname?

Posted: Tue Jan 02, 2007 11:51 pm
by Elijah Lofgren
nakuttaja wrote: Hi!

How can I fill in the Comments "user"-field with customcontent_loginname? So the user wouldn't have an option to insert it's name but it being filled automatically. I have already made that "Add comment" is only available for logged in users.

Thanks, Nakuttaja
I figured out how:
1. Open modules/Comments/action.default.php
2. Find this code:

Code: Select all

$this->smarty->assign_by_ref('inputyourname',   $this->CreateInputText($id, 'author', $author, 50, 255));
3. Replace it with:

Code: Select all

$module = $this->GetModuleInstance('FrontEndUsers');
$this->smarty->assign_by_ref('inputyourname',   $this->CreateInputHidden($id, 'author', $module->LoggedInName(), 50, 255));
4. Then go to Content » Comments and click on the "Comment Display Template" tab.
5. Replace this:

Code: Select all

	<tr>
		<td>{$yournametxt}(*):</td>
		<td>{$inputyourname}</td>
	</tr>
with this:

Code: Select all

{$inputyourname}
I've posted the PHP changes as a patch here for future reference: http://dev.cmsmadesimple.org/tracker/in ... 3&atid=171

Hope this helps,

Elijah

Re: How to fill in Comments "user" with customcontent_loginname?

Posted: Wed Jan 03, 2007 12:07 am
by nakuttaja
Elijah Lofgren wrote: ...
Thank you so much! I've been fighting with this so long. Now it works just the way I needed.

:D

Re: How to fill in Comments "user" with customcontent_loginname? [solved]

Posted: Thu Jan 04, 2007 4:33 am
by calguy1000
I'm pretty sure, though I haven't tried it.... that one could use smarty's {eval var=$whatever assign=inputyourname}..... somehow with this

http://smarty.php.net