Hello!
Is there any way to display the owner´s name on every page, the pageowner? I can get the username but not the first and last name...
Help please!
[SOLVED] Display name
-
- New Member
- Posts: 5
- Joined: Wed Jan 07, 2009 9:50 am
[SOLVED] Display name
Last edited by johan_jnsson on Thu Jan 08, 2009 4:03 pm, edited 1 time in total.
Re: Display name
Maybe add a little user defined tag?
in template:
udt: page_owner
Something like that should work (written this by heart)
in template:
Code: Select all
Page owned by {page_owner username=$username}
Code: Select all
global $gCms, $db;
$sql = "SELECT first_name, last_name FROM cms_users WHERE username = ?";
$result = $db->Execute($sql, $params['username']);
$names = $result->FetchRow();
echo $names['first-name']. " " . $names['last_name'];
Re: Display name
Hi Johan,
you could also use the content_dump plug-in for this. It is actually intended to gather information from other pages, but also works great to get owner information of the page that contains the tag.
Place it like this in your template:
You can then access (amongst others) these data fields:
You can then use these smarty data elements to do whatever you want with the data. At the end, you could do something like this in your template:
You can find more information about the plug-in here: http://wiki.cmsmadesimple.org/index.php ... ntent_dump
You can download the plug-in here: http://dev.cmsmadesimple.org/projects/contentdump
Make sure to place the tag into the template and not the content-data
Best
Nils
you could also use the content_dump plug-in for this. It is actually intended to gather information from other pages, but also works great to get owner information of the page that contains the tag.
Place it like this in your template:
Code: Select all
{content_dump this_only=$content_id users=true}
Code: Select all
$dump [ n ] -> created -> date
$dump [ n ] -> created -> by -> username
$dump [ n ] -> created -> by -> last_name
$dump [ n ] -> created -> by -> first_name
$dump [ n ] -> created -> by -> email
$dump [ n ] -> modified -> date
$dump [ n ] -> modified -> by -> username
$dump [ n ] -> modified -> by -> last_name
$dump [ n ] -> modified -> by -> first_name
$dump [ n ] -> modified -> by -> email
Code: Select all
{content_dump this_only=$content_id users=true}
<p>
This article was originally written by {$dump[0]->created->by->first_name} {$dump[0]->created->by->last_name}.
{if $dump[0]->modified->date !=$dump[0]->created->date}
This article has been modified by {$dump[0]->modified->by->first_name} {$dump[0]->modified->by->last_name}.
{/if}
</p>
You can download the plug-in here: http://dev.cmsmadesimple.org/projects/contentdump
Make sure to place the tag into the template and not the content-data

Best
Nils
Re: Display name
Or create a small, dynamic, simple UDT to be put in your template.
This will spit out the page owner for each page you display. Just put the {your UDT name} in the template. Add div's, tags and what not to get this as you would like it.
Mats
Code: Select all
global $gCms;
$db = &$gCms->GetDb();
$sql = "SELECT first_name, last_name FROM cms_users WHERE user_id=(SELECT owner_id FROM cms_content where content_id="."'".$gCms->variables['content_id']."'".")";
$result = $db->Execute($sql);
$names = $result->FetchRow();
echo $names['first_name']. " " . $names['last_name'];
Mats
Last edited by zigge on Wed Jan 07, 2009 7:09 pm, edited 1 time in total.
-
- New Member
- Posts: 5
- Joined: Wed Jan 07, 2009 9:50 am
Re: Display name
Thank you! Now I a got it to work!
Thanks once again.
Thanks once again.