Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Article by...  (Read 1452 times)

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Article by...
« on: September 30, 2009, 01:54:17 PM »

Howdee?
How can we have in the byline the name of the author (stored somewhere, but where? ;D)
I'ld like to use micro-formats and have such output:
Code: [Select]
<address class="vcard author">
By <a class="url fn">Me, myself and I</a>
</address>
That's for SEO and HTML5 experiments (website coming soon).
Any idea?

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Article by...
« Reply #1 on: September 30, 2009, 06:12:36 PM »

Probably we need something like this: http://gmpg.org/xfn/creator ?
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Article by...
« Reply #2 on: September 30, 2009, 06:25:51 PM »

Probably. ;)
For the moment I have hard-coded it in the core, but,
I think it should be modded.

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Article by...
« Reply #3 on: October 01, 2009, 01:13:54 AM »

Untested but a wild guess. You can have username as something else but you need to place it in the system somehow.... For MU there is probably another way but similar...

Code: [Select]
function singleUserAuthorLink() {
     return '<a href="mailto:'.s('website_contact').'" rel="me" class="url fn">'.s('username').'</a>';
}
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Article by...
« Reply #4 on: October 01, 2009, 08:31:25 AM »

Untested but a wild guess. You can have username as something else but you need to place it in the system somehow.... For MU there is probably another way but similar...

Code: [Select]
function singleUserAuthorLink() {
     return '<a href="mailto:'.s('website_contact').'" rel="me" class="url fn">'.s('username').'</a>';
}
That prints the encrypted login/username. ;D ;D

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Article by...
« Reply #5 on: October 01, 2009, 12:42:28 PM »

Oh I know, as I stated it was a wild guess. I really wasn't expecting you to use it, I expected you to see how it may look like and work from there.  You should add a field for your name (or author name to be shown), and/or seperate email in settings, then call it up in a function similar to the above.

There should be a better way to add an item to settings...
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Article by...
« Reply #6 on: October 01, 2009, 12:49:23 PM »

There should be a better way to add an item to settings...

Yeah, there should, but as it is you need to add a user input field with all it's related bits in snews.php so one can enter/change author name as one sees fit, and add "author" to the db data (in settings table I guess), right? The s('author') could be called in at lots of places, in the head for one thing, in comments, in byline, in an imagined about page, etc etc, but there needs to be some place where the author name can be entered/changed in the adminface. Maybe with an avatar? :D
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Article by...
« Reply #7 on: October 01, 2009, 02:20:56 PM »

There should be a better way to add an item to settings...

Yeah, there should, but as it is you need to add a user input field with all it's related bits in snews.php so one can enter/change author name as one sees fit, and add "author" to the db data (in settings table I guess), right? The s('author') could be called in at lots of places, in the head for one thing, in comments, in byline, in an imagined about page, etc etc, but there needs to be some place where the author name can be entered/changed in the adminface. Maybe with an avatar? :D

ahh I wish for plugins... it would look like this

Add to your db:
Code: [Select]
INSERT INTO `settings` (
`id` ,
`name` ,
`value`
)
VALUES (
NULL , 'site_author', ''
);

In snews.php add

After the db connection somewhere
Code: [Select]
function addPlugin( $hook, $callback ) {
global $__plugin;
$__plugin[$hook][] = array( 'callback' => $callback );
return true;
}

function execPlugin( $hook, $string = '' ) {
global $__plugin; 
if ( !isset($__plugin[$hook] ) ) return $string;
$arg = func_get_args();
foreach ( $__plugin[$hook] as $key=>$callback ) {
foreach ($callback as $call) {
$args = !empty($arg)
? array_merge( array( $string ), $arg )
: $string;
$string = call_user_func_array($call, $args);
}
}
return $string;
}

settings looks like this:
Code: [Select]
echo html_input('fieldset', '', '', '', '', '', '', '', '', '', '', '', '', '', '<a onclick="toggle(\'sub2\')" style="cursor: pointer;">'.l('a_contact_info').'</a>');
echo '<div id="sub2" style="display: none;">';
execPlugin( 'contactSetting-Beg' );
echo html_input('text', 'website_email', 'we', s('website_email'), l('a_website_email'), '', '', '', '', '', '', '', '', '', '');
echo html_input('text', 'contact_subject', 'cs', s('contact_subject'), l('a_contact_subject'), '', '', '', '', '', '', '', '', '', '');
execPlugin( 'contactSetting-End' );
echo '</div></fieldset></div><div class="adminpanel">';

processing: - only the first line
Code: [Select]
$ufield = execPlugin( 'settingsArray', $ufield );
while (list($key, $value) = each($ufield)) {

Now I have this in index adfter the include of snews.php for testing only.  Ideally, you want to have the db check if this is allowed to be installed then include the file...

Code: [Select]
addPlugin( 'contactSetting-Beg', 'authorField' );
addPlugin( 'settingsArray', 'authorProcess' );

function authorField() {
$authorField = '
<p>
<label for="AuthorSetting">Site Author</label>:
<br />
<input type="text" name="site_author" id="AuthorSetting" value="'.s('site_author').'" />
</p>';
echo $authorField;
}

function authorProcess( $array ) {
if (!isset($_POST['site_author'])) return;
else {
$author = clean(entity($_POST['site_author']));
$author = array('site_author' => $author);
$array = array_merge( $array, $author );
}
return $array;
}

Then I add what code I need:
This was done by <?php echo s('site_author'); ?>
« Last Edit: October 01, 2009, 03:34:47 PM by nukpana »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
MOD Article by...
« Reply #8 on: October 01, 2009, 04:43:35 PM »

Jason this is superb!
Very briliant!
Topic should be move to Mod's forum.
Behalf of the snoozers, thanks. :)

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: Article by...
« Reply #9 on: October 01, 2009, 08:09:44 PM »

Well for testing, thank you but this is far from complete as the system needs to be completed to be considered.  I am just noting it should be easier to set up a setting.  This could be broken down slightly further now that I look at it again...
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Article by... multi-authors enhancement
« Reply #10 on: November 04, 2009, 11:51:18 AM »

Me again in this thread where I sware, I won't talk about MU, no no no.

A couple of gals and I are planning to create a common blog where articles signed by their respective authors gonna be published.
Based on this mini-Mod (which already does a max) would it be possible to have in the administration the capability to have different authors being managed?
Goal is to assign to articles the name of its creator? Wonderin...

Wondering too if some snoozers would be interested in such a feature. ???

It's up to you: leave your message. Bip.