CGBlogs dynamic Gravatars
CGBlogs dynamic Gravatars
He team, I'm trying to add a gravatar to CGBlog that pulls from the admin/editors email. We have seven authors, and I'd like to add their avatar dynamically.
Here's what I've put in the smarty template:
{gravatar width=80 height=80 email='$author_email'}
I still can't get the email string to populate, any help would be appreciated.
Thanks team,
Emeka Rajis
Here's what I've put in the smarty template:
{gravatar width=80 height=80 email='$author_email'}
I still can't get the email string to populate, any help would be appreciated.
Thanks team,
Emeka Rajis
Re: CGBlogs dynamic Gravatars
I believe you can use {gravatar width=80 height=80 email=$author_email}...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: CGBlogs dynamic Gravatars
Still doesn't work for me
Here's my template code:
CGBLOG SUMMARY TEMPLATE:
//////////////////////////////////////////////////
...
{if $entry->author}
<div class="CGBlogSummaryAuthor">
{gravatar width=80 height=80 email=$author_email} {$author_label} {authorname username=$entry->author}
</div>
{/if}
...
//////////////////////////////////////////////////

CGBLOG SUMMARY TEMPLATE:
//////////////////////////////////////////////////
...
{if $entry->author}
<div class="CGBlogSummaryAuthor">
{gravatar width=80 height=80 email=$author_email} {$author_label} {authorname username=$entry->author}
</div>
{/if}
...
//////////////////////////////////////////////////
Re: CGBlogs dynamic Gravatars
Dear Erajis,
Smarty will only recognize vars if you enclose them in double quotes
http://www.smarty.net/docsv2/en/languag ... thor_email"[/code]
Greetings,
Manuel
Smarty will only recognize vars if you enclose them in double quotes
http://www.smarty.net/docsv2/en/languag ... thor_email"[/code]
Greetings,
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Re: CGBlogs dynamic Gravatars
Actually, that is incorrect. Otherwise this wouldn't be possible:manuel wrote:...Smarty will only recognize vars if you enclose them in double quotes...
http://www.smarty.net/docsv2/en/languag ... thor_email"[/code]
Code: Select all
{assign var=running_total value=$running_total+$some_array[$row].some_value}
http://www.smarty.net/docs/en/language. ... assign.tpl.
However email="$author_email" will evaluate the variable while email='$author_email' won't.

In any case I would check if {$author_email} actually holds a valid email...
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: CGBlogs dynamic Gravatars
Dear Jo Morg,
Oops, you are absolutely right
That's one "only" too much in my previous response
Erajis, please check the content of the var with:
Greetings,
Manuel
Oops, you are absolutely right

That's one "only" too much in my previous response
Erajis, please check the content of the var with:
Code: Select all
{$author_email|@debug_print_var}
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Re: CGBlogs dynamic Gravatars
manuel wrote:Oops, you are absolutely right
That's one "only" too much in my previous response

"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: CGBlogs dynamic Gravatars
Hey guys, the logic returned "Null" :
...
{if $entry->author}
<div class="CGBlogSummaryAuthor">
{$author_email|@debug_print_var}
{gravatar width=80 height=80 email="$author_email"} {$author_label} {authorname username=$entry->author}
</div>
{/if}
...
and my admin account has an email attached to it, so I'm not sure what the issue is...
Thanks guys for your help!
...
{if $entry->author}
<div class="CGBlogSummaryAuthor">
{$author_email|@debug_print_var}
{gravatar width=80 height=80 email="$author_email"} {$author_label} {authorname username=$entry->author}
</div>
{/if}
...
and my admin account has an email attached to it, so I'm not sure what the issue is...
Thanks guys for your help!
Re: CGBlogs dynamic Gravatars
Well... that's why http://forum.cmsmadesimple.org/viewtopi ... =40&t=2661 should be read 1st...
Where does $author_email come from? How do you generate this variable value?
There must be something wrong before the parser even gets to the sample code you actually provided.
Where does $author_email come from? How do you generate this variable value?
There must be something wrong before the parser even gets to the sample code you actually provided.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: CGBlogs dynamic Gravatars
I'm not a php, or smarty guru - so I'm not sure how to generate the value. I thought it would be as simple as {gravatar email='$author_email'}, but to no avail. I'm using the latest version of cms 1.11.3, and the latest version of CGBlog 1.9.8. -- Moreover I'm not sure how the parser works or how to evaluate it. I am making strides to learn more about smarty, and php. But this gravatar issue seems so close but yet so far! Thanks for your help, I tried to look around first before I bothered you guys about it.Jo Morg wrote:Well... that's why http://forum.cmsmadesimple.org/viewtopi ... =40&t=2661 should be read 1st...
Where does $author_email come from? How do you generate this variable value?
There must be something wrong before the parser even gets to the sample code you actually provided.
-- Any help would be appreciated.
Here's my summary template:
Code: Select all
<!-- Start CGBlog Display Template -->
{if isset($error)}{cgerror}{$error}{/cgerror}{/if}
{if $pagecount > 1}
<p>
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
{$nextpage} {$lastpage}
{/if}
</p>
{/if}
{foreach from=$items item=entry}
<div class="CGBlogSummary">
{if $entry->postdate}
<div class="CGBlogSummaryPostdate">
{$entry->postdate|cms_date_format}
</div>
{/if}
<div class="CGBlogSummaryLink">
<a href="{$entry->detail_url}" title="{$entry->title|escape:htmlall}">{$entry->title|escape}</a>
</div>
{if $entry->categories}
<div class="CGBlogSummaryCategory">
{strip}{$category_label}
{foreach from=$entry->categories item='category'}
{$category.name}
{/foreach}
{/strip}
</div>
{/if}
{if $entry->author}
<div class="CGBlogSummaryAuthor">
{gravatar width=80 height=80 email="$author_email"} {$author_label} {authorname username=$entry->author}
</div>
{/if}
{if $entry->summary}
<div class="CGBlogSummarySummary">
{eval var=$entry->summary}
</div>
{else if $entry->content}
<div class="CGBlogSummaryContent">
{eval var=$entry->content}
</div>
{/if}
{if isset($entry->extra)}
<div class="CGBlogSummaryExtra">
{eval var=$entry->extra}
{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
</div>
{/if}
{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}
<div class="CGBlogSummaryField">
{if $field->type == 'file'}
<img src="{$entry->file_location}/{$field->value}"/>
{else}
{$field->name}: {eval var=$field->value}
{/if}
</div>
{/foreach}
{/if}
</div>
{/foreach}
<!-- End CGBlog Display Template -->
Re: CGBlogs dynamic Gravatars
Well, no need to be a Smarty guru, nor (not by a long shot) a PHP guru.
.
Most of the webdesign made with CMSMS requires a basic knowledge of Smarty which is very easy.
But we can't assume that some variable is available on a certain template, just because... well, because!
CMSMS core and Modules assign values/arrays/objects to Smarty variables in order for the designer to use and manipulate at will.
It's generically documented on most cases.
That being said, try to see what variables you have available on a certain template. And after that if you want to further inspect what a certain variable holds use manuel's tip: @debug_print_var. If a certain variable doesn't exist, you may consider searching DOCs and this forum (chances are someone already found a solution). 
And by then, you will probably know what kind of help you actually need and how to ask for it.

Most of the webdesign made with CMSMS requires a basic knowledge of Smarty which is very easy.
But we can't assume that some variable is available on a certain template, just because... well, because!
CMSMS core and Modules assign values/arrays/objects to Smarty variables in order for the designer to use and manipulate at will.
It's generically documented on most cases.
That being said, try
Code: Select all
{get_template_vars}

And by then, you will probably know what kind of help you actually need and how to ask for it.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: CGBlogs dynamic Gravatars
Thank you so much, I'm hot on the chase! I'll report back once I have this solved! Thanks again for your patience!
ER
ER
Re: CGBlogs dynamic Gravatars
Okay so I'm hot on the trail. I'm trying to call the string from the database in a UDT called "getemail".
In my template I'm inserting it as:
But I'm stilling getting "null". I'm learning a lot, but sure could use some guidance. I'm getting all the CGBlog summary template variables in here is the list of what I have thus far:
Thanks guys, I'm trying to get this down!
ER
Code: Select all
global $gCms;
$db =& $gCms->GetDb();
$email = isset($params['email']) ? $params['email'] : "";
$feu_field = isset($params['feufield']) ? $params['feufield'] : "";
$query = "SELECT email FROM ".cms_db_prefix()."users WHERE email=?";
$row = $db->GetRow($query, array($user_name));
if($row){
$result = $row['email'];
}else{
if($gCms->modules['FrontEndUsers']['object'] && !empty($feu_field))
{
$query = "SELECT id FROM ".cms_db_prefix()."module_feusers_users WHERE email=?";
$feid = $db->GetOne($query, array($email));
if($feid) {
$query = "SELECT data FROM ".cms_db_prefix()."module_feusers_properties WHERE email=? AND title=?";
$result = $db->GetOne($query, array($feid,$feu_field));
}
}
}
if(!$result){
$result = "Username: $email doesn't exist or feufield is not set";}
return $result;
Code: Select all
{get_template_vars}
{$author_email|@debug_print_var}
<!-- Start CGBlog Display Template -->
{if isset($error)}{cgerror}{$error}{/cgerror}{/if}
{if $pagecount > 1}
<p>
{if $pagenumber > 1}
{$firstpage} {$prevpage}
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
{$nextpage} {$lastpage}
{/if}
</p>
{/if}
{foreach from=$items item=entry}
<div class="CGBlogSummary">
{if $entry->postdate}
<div class="CGBlogSummaryPostdate">
{$entry->postdate|cms_date_format}
</div>
{/if}
<div class="CGBlogSummaryLink">
<a href="{$entry->detail_url}" title="{$entry->title|escape:htmlall}">{$entry->title|escape}</a>
</div>
{if $entry->categories}
<div class="CGBlogSummaryCategory">
{strip}{$category_label}
{foreach from=$entry->categories item='category'}
{$category.name}
{/foreach}
{/strip}
</div>
{/if}
{if $entry->author}
<div class="CGBlogSummaryAuthor">
{gravatar width=80 height=80 email="$author_email"} {$author_label} {authorname username=$entry->author}
{getemail email=$entry->email}
</div>
{/if}
{if $entry->summary}
<div class="CGBlogSummarySummary">
{eval var=$entry->summary}
</div>
{else if $entry->content}
<div class="CGBlogSummaryContent">
{eval var=$entry->content}
</div>
{/if}
{if isset($entry->extra)}
<div class="CGBlogSummaryExtra">
{eval var=$entry->extra}
{* {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} *}
</div>
{/if}
{if isset($entry->fields)}
{foreach from=$entry->fields item='field'}
<div class="CGBlogSummaryField">
{if $field->type == 'file'}
<img src="{$entry->file_location}/{$field->value}"/>
{else}
{$field->name}: {eval var=$field->value}
{/if}
</div>
{/foreach}
{/if}
</div>
{/foreach}
<!-- End CGBlog Display Template -->
Code: Select all
app_name = CMS
cgsimple = Object
feu_smarty = Object
sitename = The X Agency
content_obj = Object
content_id = 64
page = x-blog
page_id = x-blog
page_name = x-blog
page_alias = x-blog
position = 5
friendly_position = 5
lang = en_US
encoding = utf-8
smarty =
nls = Object
gcb_params = Array (1)
actionid = mb2673
actionparams = Array (2)
returnid = 64
actionmodule = CGBlog
menuparams = Array (4)
count = 4
nodelist = Array (4)
node = Object
mod = Object
CGBlog = Object
prevpage = <
firstpage = <<
nextpage = >
lastpage = >>
pagenumber = 1
pagecount = 1
oftext = of
pagetext = Page
itemcount = 1
items = Array (1)
category_label = Category:
author_label = Posted by:
statusopts = Array (2)
param_module = CGBlog
SCRIPT_NAME = /index.php
null -- (this is my UDT result)
ER
Re: CGBlogs dynamic Gravatars
Dear Erajis,
I don't have a lot of experience with this but I believe you have to update the UDT to work with the latest CMSMS.
Please try replacingwith
with
Greetings,
Manuel
I don't have a lot of experience with this but I believe you have to update the UDT to work with the latest CMSMS.
Please try replacing
Code: Select all
global $gCms;
Code: Select all
$gCms = cmsms();
Code: Select all
$db =& $gCms->GetDb();
Code: Select all
$db = cmsms()->GetDb();
Manuel
Do you like your open source cms? Buy from the CMSMS partners || Donate
Re: CGBlogs dynamic Gravatars
Once you have $gCms you can use $gCms->GetDb()manuel wrote:Please try replacing
Code:
global $gCms;
with
Code:
$gCms = cmsms();
Code:
$db =& $gCms->GetDb();
with
Code:
$db = cmsms()->GetDb();
so this:
Code: Select all
$gCms = cmsms();
$db = $gCms->GetDb();
This is IIRC deprecated or even obsolete:
Code: Select all
$gCms->modules['FrontEndUsers']['object']
Code: Select all
$feu = cms_utils::get_module('FrontEndUsers');
Code: Select all
{gravatar width=80 height=80 email=$entry->email}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!