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>