Posts: 55
Threads: 11
Joined: May 2012
2013-02-19, 21:05:42
(This post was last modified: 2013-04-06, 00:44:40 by krysttof.)
In my template, can I display the Display Name that you can enter in the User Profil ?
If I used the tag : <?php echo $data_index->author; ?>, it's the Username which is displayed.
Is it possible ?
Thank's for your help !
Français et éternel débutant
French and eternal beginner
Posts: 102
Threads: 5
Joined: Dec 2012
Which template do you use? Which plugins?
Posts: 55
Threads: 11
Joined: May 2012
The default template (Innovation) and no plugin. Just a test on localhost.
Français et éternel débutant
French and eternal beginner
Posts: 71
Threads: 6
Joined: Feb 2013
Did you dig through the wiki?
http://get-simple.info/wiki/
and the forum:
http://get-simple.info/forums/showthread.php?tid=3371
I haven't tinkered this far yet but by glancing at:
http://code.google.com/p/get-simple-cms/...tail?r=755
It seems that you can manually get that information by parsing the user data via your functions file and echo it via php onto your template if defined.
So try:
<?php echo $data->NAME; ?>
or
<?php echo $data_index->NAME; ?>
and let us know if it works....
Posts: 102
Threads: 5
Joined: Dec 2012
2013-02-21, 22:14:35
(This post was last modified: 2013-02-21, 22:16:00 by Psychosopher.)
Author in pages is defined as username.
You can retrieve the name from the userfile in /data/users/.
But there will be also other solutions...
Posts: 55
Threads: 11
Joined: May 2012
2013-02-21, 22:45:59
(This post was last modified: 2013-02-21, 22:59:36 by krysttof.)
@WebDevandPhoto
If I use <?php echo $data->NAME; ?> or <?php echo $data_index->NAME; ?>, nothing is displayed.
With <?php echo $data_index->author; ?>, it's the Username, but not the Display Name.
The wiki page about author : author snippet
Français et éternel débutant
French and eternal beginner
Posts: 6,266
Threads: 181
Joined: Sep 2011
What version of GS are you using ?
Name is not stored in pages.
You would have to look it up in the users datafile for that user.
display name is 3.2+
psuedocode
PHP Code: if (file_exists(GSUSERSPATH . $author . '.xml')) { $data = getXML(GSUSERSPATH . $author . '.xml'); $NAME = stripslashes($data->NAME); }
Posts: 55
Threads: 11
Joined: May 2012
I use the last version, v3.2
Français et éternel débutant
French and eternal beginner
Posts: 71
Threads: 6
Joined: Feb 2013
(2013-02-21, 23:59:13)shawn_a Wrote: PHP Code: if (file_exists(GSUSERSPATH . $author . '.xml')) { $data = getXML(GSUSERSPATH . $author . '.xml'); $NAME = stripslashes($data->NAME); }
Did it work for you krysttof?
Posts: 6,266
Threads: 181
Joined: Sep 2011
If this is something you want then write a plugin or use my hook plugin.
And on page save add the display name to extra fields, then it will be in $data_index. Of course it will be static and not update.
on changedata hook
add custom field name->$datau->NAME;
Posts: 55
Threads: 11
Joined: May 2012
i used this code in my template :
Code: <?php
if (file_exists(GSUSERSPATH.$author.'.xml')) {
$data = getXML(GSUSERSPATH.$author.'.xml');
$NAME = stripslashes($data->NAME);
};
?>
And I have this error :
Code: Notice: Undefined variable: author in /Users/mymac/Sites/gs32/theme/Simple DeepBlue/template.php on line 47
Français et éternel débutant
French and eternal beginner
Posts: 6,266
Threads: 181
Joined: Sep 2011
That waspsuedo code, you have to define author or use data index author
Posts: 55
Threads: 11
Joined: May 2012
shawn_a,
I'm really sorry, I'm a newbie with PHP, so I don't know what to do with your code, with the variables $author, $data_index, $NAME...
Français et éternel débutant
French and eternal beginner
Posts: 55
Threads: 11
Joined: May 2012
No little help ?
Français et éternel débutant
French and eternal beginner
Posts: 6,266
Threads: 181
Joined: Sep 2011
$data_index->author; its in the first post you posted.
Posts: 6,266
Threads: 181
Joined: Sep 2011
Where are you putting this code theme , component function ?
Posts: 6,266
Threads: 181
Joined: Sep 2011
PHP Code: <?php if (file_exists(GSUSERSPATH.$data_index->author.'.xml')) { $data = getXML(GSUSERSPATH.$author.'.xml'); $NAME = stripslashes($data->NAME); }; ?>
Posts: 55
Threads: 11
Joined: May 2012
2013-04-05, 16:41:25
(This post was last modified: 2013-04-05, 16:51:44 by krysttof.)
shawn_a, if I put your previous PHP Code (#17) in my template.php file, nothing is displayed !
I guess I have to displayed a variable ?
But wath variable ?
And how ?
cf my post #13
Français et éternel débutant
French and eternal beginner
Posts: 6,266
Threads: 181
Joined: Sep 2011
that is just the function you have to echo $NAME somewhere.
Posts: 55
Threads: 11
Joined: May 2012
In my functions.php, I have this code :
PHP Code: if (file_exists(GSUSERSPATH.$data_index->author.'.xml')) { $data = getXML(GSUSERSPATH.$author.'.xml'); $NAME = stripslashes($data->NAME); }
In my template.php file, I have this code :
PHP Code: <p>Auteur : <?php echo $NAME; ?></p>
Nothing is displayed and I have two errors :
PHP Code: Notice: Undefined variable: author in /Users/mymac/Sites/gs-site/theme/mytheme/functions.php on line 51 Notice: Trying to get property of non-object in /Users/mymac/Sites/gs-site/theme/mytheme/functions.php on line 52
The line 51 : $data = getXML(GSUSERSPATH.$author.'.xml');
The line 52 : $NAME = stripslashes($data->NAME);
Français et éternel débutant
French and eternal beginner
Posts: 6,266
Threads: 181
Joined: Sep 2011
sorry
PHP Code: <?php
$author = $data_index->author; if ($author && file_exists(GSUSERSPATH.$author.'.xml')) { $data = getXML(GSUSERSPATH.$author.'.xml'); $NAME = stripslashes($data->NAME); }; ?>
Posts: 55
Threads: 11
Joined: May 2012
Finally it works! The name is displayed!
It was not easy for me, a big thank you shawn_a !
Français et éternel débutant
French and eternal beginner
Posts: 6,266
Threads: 181
Joined: Sep 2011
No problem , it probably needs to be cleaned up to handle empty display names and stuff, but like i said untested code, maybe we we will have something better in a few versions.
Posts: 55
Threads: 11
Joined: May 2012
Yes !, it might be interesting in the future to have an "official template tag" to display the name in the template.
Français et éternel débutant
French and eternal beginner
Posts: 321
Threads: 15
Joined: Feb 2012
(2013-04-06, 00:39:17)shawn_a Wrote: sorry
PHP Code: It still work fine.
<?php
$author = $data_index->author; if ($author && file_exists(GSUSERSPATH.$author.'.xml')) { $data = getXML(GSUSERSPATH.$author.'.xml'); $NAME = stripslashes($data->NAME); }; ?>
My website made with GetSimple CMS is
Arte & Società
www.artesocieta.eu
An indipendent website about Italian Contemporary Visual Arts
|