Page 1 of 1

News module: howto show author's name?

Posted: Fri Sep 08, 2006 9:00 am
by numer9
Hey,
in news module, i want to show author-of-the-article name or alias. There is an option during adding new user to give firstname and lastname, how can I reach it from the news template?

I want to modify $entry->author so that i'll reach the real name, not the login name...

maybe i'm just blind, but been searching for the answer for so long and nothing - maybe someone will help me?

Re: News module: howto show author's name?

Posted: Fri Sep 08, 2006 9:26 am
by cyberman
numer9 wrote: I want to modify $entry->author so that i'll reach the real name, not the login name...
Have you tried $entry->authorname ? (seen in News 2.1 help)

Re: News module: howto show author's name?

Posted: Mon Sep 11, 2006 10:19 pm
by numer9
:o

big thanks man. I was pretty sure I checked all possibilities, but what i did it was $entry->authorsname, with "s" in the middle :(

and maybe there a chance to divide between first and last name? :)
and another one - is there a chance to easily modify the author? I mean - if someone added the news-article, but I want to show another author (another cms ms user of course). And I don't want to go into the core database (that's the way i'm doing it right now), is there a way to do it "smoothly"?

thanks again!

Re: News module: howto show author's name?

Posted: Tue Sep 12, 2006 12:52 pm
by cyberman
numer9 wrote: maybe there a chance to divide between first and last name? :)
For this you have to modify source of action.default.php. Go to line 128
$onerow->authorname = $row['first_name'].' '.$row['last_name'];
and change it to

Code: Select all

			$onerow->authorfirst = $row['first_name'];
			$onerow->authorlast = $row['last_name'];
Now you can use values authorfirst and authorlast in template like this

Code: Select all

		Posted by: {$entry->authorfirst} {$entry->authorlast}
and another one - is there a chance to easily modify the author?
I think for this action.editarticle.php must be modified. I'm trying something - please wait for my reply.

Re: News module: howto show author's name?

Posted: Tue Sep 12, 2006 1:20 pm
by tsw
Tried to find smarty function for this but it seems there is only one which would be suitable, and this is more of a hack ;)

and untested :)

from http://smarty.php.net/manual/en/languag ... eplace.php

{$entry->authorname|regex_replace:"/ .*/":""} would print first name and

{$entry->authorname|regex_replace:"/.* /":""} would print last name IF there is a space between the names

the power of regexp ;)

Re: News module: howto show author's name?

Posted: Wed Sep 13, 2006 9:22 am
by numer9
now I know almost everything about this feature :)

big thanks for now (waiting for more, of course ;))

:D

Re: News module: howto show author's name?

Posted: Thu Sep 14, 2006 10:40 am
by cyberman
numer9 wrote: big thanks for now (waiting for more, of course ;))
Have submitted my hack for changing news author here

http://dev.cmsmadesimple.org/tracker/in ... 8&atid=111

Re: News module: howto show author's name?

Posted: Fri Sep 15, 2006 12:16 pm
by numer9
Ok, thanks for getting involved :)

one more question - won't uninstall-and-install news module remove all the current news? Cause my problems is about "live" site, so i can't afford loosing all the news. In first spare moment i'll do a backup and try it on backup copy, but maybe you've tested it already?

thanks!

Re: News module: howto show author's name?

Posted: Fri Sep 15, 2006 12:46 pm
by cyberman
Yes, all news will be removed. Please look once again to my hack, have added forgotten files for an upgrade :) ...

But a backup is a very good idea every time before upgrading.

Re: News module: howto show author's name?

Posted: Fri Sep 15, 2006 1:01 pm
by numer9
Yap, backup is definetly good thing before doing anything on "live organism" :) But it takes some time. Especially in this case - i don't have a shell account, it's just ftp access to the files and phpMyAdmin to SQL... so downloading, then uploading to test env, upgrading, uploading again... and there goes another hour of work ;)

and thanks for the patch. In first spare moment I'll try that and keep you informed about it  :D

Re: News module: howto show author's name?

Posted: Fri Sep 29, 2006 11:14 am
by numer9
BTW - i got another one... i want to show photo in summary (small) and i want it to be bigger in content... is there any support for automatic photo embedding in News? I mean i know i can insert img src... tag inside the summary and content, but that's not the good solution, since the small photo will show up also in detailed template look...

i hope i'm clear ;)

Re: News module: howto show author's name?

Posted: Fri Sep 29, 2006 12:50 pm
by cyberman
numer9 wrote: I mean i know i can insert img src... tag inside the summary and content, but that's not the good solution, since the small photo will show up also in detailed template look...
IMHO small photo will not show up if you use different templates for summary and details view ...

Re: News module: howto show author's name?

Posted: Fri Sep 29, 2006 1:51 pm
by Dr.CSS
If it does you can make it go away with CSS...

#NewsPostDetailSummary img {display: none}