Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Name of Author
#1
Is there a way to show the author of a page?
Reply
#2
Use 'i18,-custom-fields', setup your format, an include in your page header.
http://get-simple.info/extend/export/290...fields.zip
Reply
#3
Paste this code in the place you'd like to show the author
Code:
<?php getPageContent(return_page_slug(),'author'); ?>

This call will actually show only user login, not user's display name which can be set in GS settings after logging in.
Addons: getsimple theme, Online Visitors, Notepad
Reply
#4
The code you should call in your theme should be:
Code:
<?php get_custom_field('myname'); ?> will display the corresponding field value for the current page. This needs to be in your theme template where you want it to show up.
Look for "configure Custom Fields" in the right hand menu on the 'Plugins page'.
Reply
#5
See here:

http://get-simple.info/wiki/theme:templa...e_snippets
Reply
#6
Thanks to eatons, yojoe and datiswous
to replying me. The both ways to show the author are interesting. Thanks again.
Reply
#7
Ill give you a real function for this later on today
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#8
Hi Shawn, it could be great THANKS!
At the moment I am using this
<?php getPageContent(return_page_slug(),'author'); ?>
Of ocurse it gives me only the Username, but better of nothing!
Reply
#9
Yeah but it opens you up to easier hacking, giving out your username
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#10
Yes, I know this is why I would like to have an alternative solution.
For now I show the usernames stylized with "text-transform:capitalize;".
Reply
#11
When the function? Smile
Reply
#12
Apples and oranges!
With custom fields, the setup is good for any authorized user to be the author and use any name they choose.
Reply
#13
Sorry stuff came up, maybe today.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#14
@shawn_a
No hurry. In part, I have already solved the problem and that's okay for me. But I think that a function such as "Posted by authorName - 17/03/2013 22:37:08" is essential. So that GS has nothing less than other cms.



@eatons
I haven't tried yet the 'i18,-custom-fields' plugin, because I'm making changes on a working online site. I usually do not want to burden my site with too many plugins but I think I'll try it soon. Thanks again for the tip. Cocos & Bananas!
Reply
#15
Sorry, I thought the function:

Quote:Profile settings now contain field for setting a display name for the user.

would do this automaticly. But I never tested it.
Reply
#16
We can do it automatically, but usernames do not change, display name can. So there lies a problem of consistency. So we are looking into several possible ways of doing this, loading user files each time a function is called and fetching the display name, or using a users cache to load in usernames, just like page cache. We are looking at several other caches also so trying to evaluate best method before implementing anything in core.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#17
Adding the name of author, GetSimple will be complete.
Reply
#18
I've used <?php getPageContent(return_page_slug(),'author'); ?> but all I get echoed is the username. How do I get the display name of the user please. It's there in the website.xml properties but not in the page properties.
Reply
#19
(2016-11-01, 03:29:04)tibbz Wrote: I've used <?php getPageContent(return_page_slug(),'author'); ?> but all I get echoed is the username. How do I get the display name of the user please. It's there in the website.xml properties but not in the page properties.

Hi tibbz, 
yes it was my same problem and I "resolved" it in this simple way:

<p>Article by <b style="text-transform: capitalize;">
<?php echo str_replace ( '-', ' ', returnPageField( return_page_slug(), 'author' ) ); ?>
</b></p>

So, for Example, an username name-surname will be displayed as Name Surname.
Much better no? Let me know if it works.
Reply
#20
(2016-11-01, 03:29:04)tibbz Wrote: I've used <?php getPageContent(return_page_slug(),'author'); ?> but all I get echoed is the username. How do I get the display name of the user please. It's there in the website.xml properties but not in the page properties.

Insert this in your theme's functions.php file (create it if it doesn't exist):

Code:
if(!function_exists('get_page_author')) {
    function get_page_author($echo=true) {
      global $GSNAME, $data_index;
      if (!$GSNAME) {
      $author = (string)$data_index->author;
      if (file_exists(GSUSERSPATH.$author.'.xml')) {
        $userxml = getXML(GSUSERSPATH.$author.'.xml');
        $GSNAME = !empty($userxml->NAME) ? htmlspecialchars($userxml->NAME) : $author;
      } else {
        $GSNAME = $author;
      }
    }
    if ($echo)
      echo $GSNAME;
    else
      return $GSNAME;
    }
}

Then, you can display the page author name in your template with:
Code:
<?php get_page_author(); ?>
Reply
#21
Many thanks both of you - great support to a great CMS.
Reply
#22
Yes - corrected.
Reply
#23
(2016-11-05, 12:19:53)tibbz Wrote: Many thanks both of you - great support to a great CMS.

You're welcome!
Reply




Users browsing this thread: 1 Guest(s)
Free HDTV Channels Residential Solar Panels