General UDT Question re: accessing module output etc
Posted: Mon Feb 25, 2013 3:30 am
I've got a general product support question but am showing a specific example to illustrate what I'm trying to learn.
When a UDT is invoked I want it to be able to invoke a module and retrieve its output data.
For example when a user gets to a certain page I want to log that into a database table. I was able to get my UDT to access and write into my table but I couldn't figure out how determine which user was on the page. I figured since the user had already logged in then his user id must be available somewhere. I found reference to putting $smarty = cmsms()->GetSmarty(); in a UDT but couldn't find what I was looking for (although it might be in there.) So I brute forced it. In my page content I did this: Then in my page_timestamp UDT I had the line:to get the id. As mentioned that seems a bit clunky but works.
However I'm now playing around with events and this approach doesn't (seem to) work with events. Again a specific example but a general lack of understanding...
I've installed the JM_forum module and want on an "OnNewTopic" event to invoke a UDT that provides me information of the last posts so that I can do stuff with them. (e.g. poor man's email notification.) So for example from a page (or GCB) I can get that information by doing this.So I guess my question boils down to how does one 'call' a module from within a UDT and then assign its output to php variables? (I think I understand smarty assignment the other way. e.g. pulling in php variables and then accessing them for displaying. Something like $smarty->assign('name', 'george smith'); {$name} but other than pulling passed parameters from the $params array I'm a bit stuck. -Thx-
When a UDT is invoked I want it to be able to invoke a module and retrieve its output data.
For example when a user gets to a certain page I want to log that into a database table. I was able to get my UDT to access and write into my table but I couldn't figure out how determine which user was on the page. I figured since the user had already logged in then his user id must be available somewhere. I found reference to putting $smarty = cmsms()->GetSmarty(); in a UDT but couldn't find what I was looking for (although it might be in there.) So I brute forced it. In my page content I did this:
Code: Select all
{FrontEndUsers form="silent"}
{page_timestamp id=$userid}
Code: Select all
$id = $params['id']) ? $params['id'];
However I'm now playing around with events and this approach doesn't (seem to) work with events. Again a specific example but a general lack of understanding...
I've installed the JM_forum module and want on an "OnNewTopic" event to invoke a UDT that provides me information of the last posts so that I can do stuff with them. (e.g. poor man's email notification.) So for example from a page (or GCB) I can get that information by doing this.
Code: Select all
{JM_Forum action="last_posts" assign="junk"}
<pre>
{if $itemcount > 0}
{foreach from=$items item=entry}
{$entry->forum_name|cms_html_entity_decode}
{$entry->subject|cms_html_entity_decode}
{$entry->body|trim|strip_tags|summarize:40}
{$entry->last_poster_time|rfc_date}
{$entry->url}#msg{$entry->post_id}
{/foreach}
{/if}
</pre>