By Sunny on Monday, 23 February 2015
Replies 9
Likes 0
Views 873
Votes 0
I wanted some clarifications on creating a stream record, as i'm trying to replicate Creating A Stream in the developers documentation.

I'm trying to follow 'Example: Uploading a new photo', but for a string from my component and not for photo, on line 8 -> $template->setContext( $photoId , 'photos' );
what should replaced by 'photos' for posting a string created by my component in context id?
(in setContext( $ID , '?????');
which contextType we should add??.)

Secondly would Creating a Stream Record be enough or do i also have to create an app?

regards
Hello Sunny,

That should be the context id and context type. It could be anything, from your custom component. Whatever that distinguishes your item. Some example of contexts:

context id: article id , context type: article
context id: blog id, context type: blog
context id: forum id, context type: forum

Upon creating the stream, you should also create an app to manipulate the display of the stream. Why is this more ideal than caching contents? If you are not going to use an app to display stream contents, and store the contents before hand, translations will never occur. Also, when something changes on the site, the content wouldn't be updated either.
·
Monday, 23 February 2015 15:50
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,
Thanks for your explanation, i've managed to get user streams by plugging my custom component to article app, its working fine.

Now also i'm trying to create a broadcast message for the leaderboard of my custom component, which will broadcast to all user streams e.g "User is the current leader at 10.30am"

For achieving this i'm trying to use the "Example: Broadcasting a new mesasge" in your docs, but i'm getting an error in
$template->setSideWide( true );

Is this because i'm trying to run this through a cron file in my root folder and user is not defined?

can you please direct me in the right direction to solve this.

warm regards
·
Monday, 02 March 2015 15:34
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Sunny,

It should actually be setSiteWide instead of setSideWide.
·
Tuesday, 03 March 2015 00:22
·
0 Likes
·
0 Votes
·
0 Comments
·
It should actually be setSiteWide instead of setSideWide.

I'm confused whats the difference between setSiteWide & setSideWide.

in my code the line 50 is
$template->setSideWide( true );

regards
·
Tuesday, 03 March 2015 13:07
·
0 Likes
·
0 Votes
·
0 Comments
·
You had a typo, it should be setSiteWide NOT setSideWide
·
Tuesday, 03 March 2015 14:06
·
0 Likes
·
0 Votes
·
0 Comments
·
& i was breaking my head!!

Thanks for pointing out

regards
·
Tuesday, 03 March 2015 14:52
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Sunny,

You are most welcome. Glad that you have identify the issue and solved it
·
Tuesday, 03 March 2015 18:59
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Azrul/Mark,

I've successfully created a brodcast message which i run through a cron, wherin the leaderboard ranks are broadcast.

$my         = Foundry::user();
$stream = Foundry::stream();
$template = $stream->getTemplate();
$template->setActor( $my->id , 'user' );
$template->setTitle( $title );
$template->setContext( $message , 'broadcast' );
$template->setVerb( 'create' );
$template->setSiteWide( true );
$stream->add( $template );


Can you please do let me know how do i add the user ID 492 (Administrator) so that the avatar of admin is shown instead of a blank avatar.

I tried -->
$template->setActor( $my->id , '492' );
but it did not have any effect.

regards

p.s : in the docs there is a typo setSideWide (instead of setSiteWide)
http://stackideas.com/docs/easysocial/developers/stream/creating-a-stream
·
Tuesday, 05 May 2015 22:14
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Sunny,

for the $template->setActor() function, the syntax is setActor($id, $type). So if you want to display the user with user ID 492, your code should be like this,

$template->setActor('492', 'user');


Hope these help
·
Wednesday, 06 May 2015 12:21
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post