News module: howto show author's name?

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
numer9

News module: howto show author's name?

Post 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?
cyberman

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

Post 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)
numer9

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

Post 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!
Last edited by numer9 on Mon Sep 11, 2006 10:28 pm, edited 1 time in total.
cyberman

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

Post 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.
Last edited by cyberman on Tue Sep 12, 2006 1:06 pm, edited 1 time in total.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

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

Post 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 ;)
numer9

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

Post by numer9 »

now I know almost everything about this feature :)

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

:D
Last edited by numer9 on Wed Sep 13, 2006 9:27 am, edited 1 time in total.
cyberman

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

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

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

Post 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!
cyberman

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

Post 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.
numer9

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

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

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

Post 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 ;)
cyberman

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

Post 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 ...
Last edited by cyberman on Fri Sep 29, 2006 12:52 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

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

Post by Dr.CSS »

If it does you can make it go away with CSS...

#NewsPostDetailSummary img {display: none}
Locked

Return to “CMSMS Core”