Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: the author's name in the articles  (Read 674 times)

adminphp

  • Full Member
  • ***
  • Karma: 2
  • Posts: 175
  • you must be a great snewser .
the author's name in the articles
« on: March 22, 2012, 05:06:59 AM »

Hi everyone, i hope you are well
i have a request for you.
all my articles which i post them everyday in my snews, Contains a line at the begining of each article this line of words include some times the author's name.

title
____
picture.   author: adminphp
_____   text text t text
text text text text.

but to do put the author name in the head of article, constantly i have to put html code include the informations.
but my request is to achieve this but just from the cpanel of the snews, i mean there will be a put textarea that would be filled by the author's name. and automatically it will display in the article .. its possible that my demand is not perfect explained, but i can do more if you hadn't got the point.   thanks
« Last Edit: March 22, 2012, 05:09:16 AM by adminphp »
Logged
“Fifty years of programming language research, and we end up with C++?”

adminphp

  • Full Member
  • ***
  • Karma: 2
  • Posts: 175
  • you must be a great snewser .
Re: the author's name in the articles
« Reply #1 on: March 23, 2012, 09:21:23 PM »

 :-[ :-[ :-[
Logged
“Fifty years of programming language research, and we end up with C++?”

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6230
  • Semantically Challenged
    • snews.ca
Re: the author's name in the articles
« Reply #2 on: March 24, 2012, 10:22:12 PM »

If you were using a Multi-User version of sNews I think it has mods in it that will show the user (author's) name or username in the info-line that gets generated below the articles (which includes the EDIT link when users are logged in).

It retrieves the user's username from the users table that the Multi-User version has in its database, and includes it in the info-line below the articles.

To do this with a Single-User version of sNews 1.6, you could hard-code your name or username into the infoline so it is displayed on every article's infoline.

1) Search your snews.php file for function tags($tag) {
    The line below it includes this:
   $tags['infoline'] = '<p class="date">,readmore,comments,date, by Username, edit,</p>';

2) Comment the line out and add this one under it:
   $tags['infoline'] = '<p class="date">'.db('author').',date,&nbsp;,readmore,comments,edit,</p>';

3) Above return $db[$variable]; in the Database Variables function (at the top of snews.php) add:
   # Adds Author name line into function tags($tag) - change the value as you wish
        $db['author'] = 'By: Author Name on ';

Now all you need to do is change Author Name to your name when you configure your database settings and it will show in your article infolines.

If you wanted to have a field in your New and Edit Article admin panels, that would take more work. You'd need to:
1) add the field to the function that generates the New and Edit panels,
2) add a new author data value to the articles table in the database,
3) modify the SQL queries in all functions that retrireve and save articles data to the database so the new value is always included.
« Last Edit: March 24, 2012, 10:23:55 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

adminphp

  • Full Member
  • ***
  • Karma: 2
  • Posts: 175
  • you must be a great snewser .
Re: the author's name in the articles
« Reply #3 on: March 27, 2012, 05:33:00 AM »

first thanks so much for your quick reply after  :-[, yes keyrocks the last thing you mentioned is what i wanted.
if I follow the first mod you posted it, which works with multipe users that i don't have it actually in my snews. And the mod i need; can display several different author's name; post many article by different authors. and thier name have not to be edited from the data base or all whenever want to change the name i need to edit snews php.
the second step looks great if it could be done, but i am confused about how to do that, just to remind, i want author's name to be displayed not in the infoline of article but at the first line of it.
for example;
author: keyrocks . text text text text
text text text etc...


thanks very much. i know mr. key you could have the key for this case but you couldn't have time to help. I understand that.
if some please, can post any details about how to work this function, i am here..
« Last Edit: March 27, 2012, 05:36:07 AM by adminphp »
Logged
“Fifty years of programming language research, and we end up with C++?”

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6230
  • Semantically Challenged
    • snews.ca
Re: the author's name in the articles
« Reply #4 on: March 27, 2012, 10:46:55 PM »

OK. This should give you what you are looking for.
The same steps would apply to any new field and data value you might want to add this way.
For sNews 1.6, Single user:

Step One:
To add the author value to your articles table, run the following SQL query on your existing database from phpMyAdmin:
Code: [Select]
ALTER TABLE `articles`
ADD (`author` varchar(100) default NULL );


Step Two: Changes to snews.php

In // ARTICLES FORM  function:

1)  Search for:
Code: [Select]
$frm_sef_title = $_SESSION['temp']['seftitle'] ? cleanSEF($_SESSION['temp']['seftitle']) : $r['seftitle'];

... and below it, paste in:
Code: [Select]
$frm_author = $_SESSION['temp']['author'] ? $_SESSION['temp']['author'] : $r['author']; // author mod

2)  Search for: $frm_submit = l('submit'); and insert under it:
Code: [Select]
$frm_author = $_SESSION['temp']['author']; // author mod

3)  Search for: echo html_input('textarea', 'text', 'txt', and insert above it to make the Author text field in the New & Edit Article and Page panels:
Code: [Select]
echo html_input('text', 'author', 'auth', $frm_author, 'Author', '', '', '', '', '', '', '', '', '', '');

In function processing()

1) Search for $seftitle = $_POST['seftitle']; and paste under it:
Code: [Select]
$author = $_POST['author']; // author mod

2) Search for case(isset($_POST['add_article'])): and replace the query string with this one to save the author value when creating a new article or page:
Code: [Select]
mysql_query("INSERT INTO ".db('prefix')."articles(title, seftitle, text, date, category, position, displaytitle, displayinfo, commentable, published, description_meta, keywords_meta, author) VALUES('$title', '$seftitle', '$text', '$date', '$category', '$position', '$display_title', '$display_info', '$commentable', '$publish_article', '$description_meta', '$keywords_meta', '$author')");

3) And four lines below that, replace the query string with this one to save the author value when editing and article or page:
Code: [Select]
mysql_query("UPDATE ".db('prefix')."articles SET title='$title', seftitle = '$seftitle', text = '$text',".$future." category = '$category', position = '$position', displaytitle = '$display_title', displayinfo = '$display_info', commentable = '$commentable', published = '$publish_article', description_meta = '$description_meta', keywords_meta = '$keywords_meta', author = '$author' WHERE id = '$id' LIMIT 1;");


In function center():

1) Search for $title = $r['title']; and under it paste in the following to get the author value for display:
Code: [Select]
$author = $r['author']; // author mod

2) And, three lines below it, under the line that starts with echo '<h2>'.(strlen($text) > paste in (before the closing bracket) to display the author name just under the article or page title:
Code: [Select]
        if (!empty($author) && $author != 'null') { echo 'By: '.$author.''; }

And you will be finished!
« Last Edit: March 27, 2012, 10:50:47 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU