By Julian on Friday, 03 July 2015
Replies 3
Likes 0
Views 0.9K
Votes 0
Hi everybody,

I guess I have a very special installation:
I use Easysocial on different domains but with the same userdatabase connected with Mighty Sites. This way I can "specialize" every page and there is no need to install all extensions on the same website.

However, the EasySocial-Userdata is shared across all websites and so is the activity-stream. This leads into an interesting situation: Naturally the links in the stream-items are relative. I would like to make them absolute, so every activity-stream can point to a different domain.

Here an example:
Website A is my "main" Easysocial-Website.
Website B has Kunena installed.

How a user writes a Kunena-posting, the url of the posting is ".../firstpost". Naturally this item would be relative on every url. On website A the stream-link would be http://www.websitea.com/firstpost and on Website B it would be http://www.websiteb.com/firstbost

Now I would like to hack the plugin that creates the activity-item and hardcode the link. When a Kunena-Item is created, the activity should ALWAYS contain a link to website b.

I guess that this shold be possible, because MightySites is configured so ONLY the tables are shared. Every website has it´s own files. So when I hack the plugin on Website B, it should only be used when a user writes the posting on website B. This way, when a User klicks on the kunena-activity, he would always be directed to website B.

Did you understand what I mean?
Possible?

All the best, Julian!
Hi Julian,

To be frank with you, we haven't try something like that with EasySocial But yeah, with some customisation, i think its possible. From what i see, you will need to customise two place. The EasySocial plugin for kunena that insert the stream, and the kunena apps that display the stream output.

EasySocial plugin for kunena:
( JOOMLA/easysocial/plugins/kunena/easysocial/activity.php )

In this plugin, you will need to find the place that calling $stream->add. This is where we add stream item into EasySocial. e.g at line 61.

$stream->add( $tmpl );

Now, you will need to add your hardcode url before this $stream->add and put it under stream params.

e.g.


$obj = stdClass();
$obj->topic_url = ‘hardcode_topic_url’;
$obj->category_url = ‘hardcode_category_url’;

$stream->addParams($obj);


so the complete code should be:


$stream = FD::stream();

$tmpl = $stream->getTemplate();

$tmpl->setActor( $message->userid , SOCIAL_TYPE_USER );
$tmpl->setContext( $message->thread , 'kunena' );
$tmpl->setVerb( 'create' );
$tmpl->setAccess( 'core.view' );

$obj = stdClass();
$obj->topic_url = ‘hardcode_topic_url’;
$obj->category_url = ‘hardcode_category_url’;

$stream->addParams($obj);

$stream->add( $tmpl );


Now, we have added the hardcoded url, we need to retrieve this url and use in stream item.

Kunena App:
(JOOMLA/media/com_easysocial/apps/user/kunena/kunena.php)

The kunena apps is used to generate the stream content. Now, we need to get back the urls that we just saved in the params. Take a look at this function processNewTopic(), add below code at line after 288:


$obj = FD::json()->decode($item->params);
$this->set( ‘obj’ , $obj );


Next, we need to access the object in the template file that display the stream title and content.

Open file JOOMLA/media/com_easysocial/apps/user/kunena/themes/default/streams/create.title.php

replace: $topic->getCategory()->getUrl()
with: $obj-> category_url

Open file JOOMLA/media/com_easysocial/apps/user/kunena/themes/default/streams/create.content.php

and replace $topic->getUrl() and $topic->getPermaUrl()
with: $obj->topic_url

The above example are only for new thread creation. You might need to do for other stream type.

Hope this help and have a nice day.
Sam
·
Friday, 03 July 2015 17:48
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Sam,


To be frank with you, we haven't try something like that with EasySocial


I thought so.
But ... I guess this is a very usefull testing for you.
There are big benefits in this kind of setup:

- EasySocial is slow, as well as Easyblog and Easydiscuss. By spreading the community through different URLs with different databases evey single page will get faster.

- I can set up a "new" community and instantly have lots of (active) users. Every website looks like a big community. If I would make single installations it would be plenty small communitys.

- As I also have connected Joomla-Articles, Komento and some other extensions, I don´t need to moderate and administrate all single pages. I only have to do it once, and it works for all communities.

I could imagine, that there are a few other webmasters out there that love this setup. That´s one of the reasons I explained it in detail.

Next, we need to access the object in the template file that display the stream title and content.

Open file JOOMLA/media/com_easysocial/apps/user/kunena/themes/default/streams/create.title.php

replace: $topic->getCategory()->getUrl()
with: $obj-> category_url

Open file JOOMLA/media/com_easysocial/apps/user/kunena/themes/default/streams/create.content.php

and replace $topic->getUrl() and $topic->getPermaUrl()
with: $obj->topic_url


I am not a coder, but I think, with this modifications I would create a new variable called "PermaUrl" beside the existing "Url" and then exchange the call of this variable.

Wouldn´t it be much easier if I manipulate the "Url" itself? When I only take the last file you mentioned, the template for the stream-item, there is just one single line in it:

<?php echo JText::sprintf( 'APP_USER_KUNENA_STREAM_CREATED' , $this->html( 'html.user' , $actor->id ) , '<a href="' . $topic->getCategory()->getUrl() . '">' . $topic->getCategory()->name ); ?>


Wouldn´t it be possible to manipulate it like this:


<?php echo JText::sprintf( 'APP_USER_KUNENA_STREAM_CREATED' , $this->html( 'html.user' , $actor->id ) , '<a href="http://www.mydomain.com/forum/' . $topic->getCategory()->getUrl() . '">' . $topic->getCategory()->name ); ?>


I am sure that this is not the way, coders would prefer. But ... it would make it much easier. I simply hardocde the absolute URL before the relative part and that´s it. No new objects, no new varialbes, and hardcodet. Certainly I would have to do that for the content-item as well.

But wouldn´t it solve the whole problem with just ONE file-manipulation, and in addition have the benefit of being easy to also manipulate it in other stream-item-plugins?

All the best, J ulian!
·
Friday, 03 July 2015 22:45
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Julian,

Thanks for heads up on this one.

Yeah, you can hardcode the url in your template file but thats also mean, you will need to do that in your sitea and siteb

Hope this help and have a nice day!
Sam
·
Tuesday, 07 July 2015 13:38
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post