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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
nakuttaja

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

Post 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
Last edited by nakuttaja on Wed Jan 03, 2007 12:16 am, edited 1 time in total.
nakuttaja

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

Post by nakuttaja »

Sorry to bring this up, but I still haven't find the answer.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

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

Post 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
nakuttaja

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

Post 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  :-\
nakuttaja

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

Post by nakuttaja »

up.

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

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

Post 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);
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

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

Post 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
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
nakuttaja

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

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Locked

Return to “CMSMS Core”