By Alexandre Cayer on Friday, 14 November 2014
Posted in Technical Issues
Replies 15
Likes 0
Views 831
Votes 0
Hi Guys,

I have only use your table object once and never with this type... could you have a look, i just wrote it from scratch dho :P

public function onRegisterAfterSave(&$post, &$user)
{
$desc = $this->params->get('default');

$group = Foundry::table('Cluster');

$group->category_id = '4';
$group->cluster_type = 'group';
$group->creator_type = 'user';
$group->creator_uid = $user->id;
$group->title = $post['name'];
$group->description = $desc;
$group->alias = $post['permalink'];
$group->target_id = $usertoassign;
$group->state = 1;
$group->featured = 1;
$group->type = 3;
$group->parent_id = 0;
$a=JFactory::getDate()->toSql();
$group->created = $a;

$group->store();

$data = array('permalink' => $post['permalink']);
$table = Foundry::table('Cluster');
$table->load($data);

$cluster = Foundry::table('ClusterNode');

$cluster->cluster_id = $table->id;
$cluster->uid = $user->id;
$cluster->type = 'user';
$cluster->created = $a;
$cluster->state = 1;
$cluster->owner = 1;
$cluster->admin = 1;
$cluster->invited_by = 0;

$cluster->store();
}
Holy stupid me...
$data = array('permalink' => $post['permalink']);

...

$data = array('alias' => $post['permalink']);

Not enough coffee sorry Jason
·
Friday, 14 November 2014 11:14
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

What errors are you getting?
·
Friday, 14 November 2014 10:55
·
0 Likes
·
0 Votes
·
0 Comments
·
0 - Missing field in database: SocialTableCluster
·
Friday, 14 November 2014 10:56
·
0 Likes
·
0 Votes
·
0 Comments
·
The permalink doesn't get in the post variable... thats the issue:
$group->alias = $post['permalink'];

This becomes empty
·
Friday, 14 November 2014 11:05
·
0 Likes
·
0 Votes
·
0 Comments
·
However, the permalink doesn't save but the group gets created... without alias dho
·
Friday, 14 November 2014 11:16
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Alex,

Wait I am confused. Can you rephrase?

Also, I don't think you need to reload the table. After doing $group->store(), you actually already have access to $group->id as the ID you want.

$data = array('permalink' => $post['permalink']);
$table = Foundry::table('Cluster');
$table->load($data);

This part is actually not needed.
·
Friday, 14 November 2014 11:27
·
0 Likes
·
0 Votes
·
0 Comments
·
I have remove the table load... how can i get the permalink TEXT and not the permalink URL ?
tried getPermalink() and getAlias() which both didnt work :/ the post value was empty... thus I have to retrieve the value some other way
·
Friday, 14 November 2014 11:48
·
0 Likes
·
0 Votes
·
0 Comments
·
Wouldn't $group->alias returns you the permalink text directly?
·
Friday, 14 November 2014 11:59
·
0 Likes
·
0 Votes
·
0 Comments
·
I want the permalink text enter during registration to be the same one for the group
$group->alias = $user->permalink;

it doesn't work... neither $group->alias = $user->getPermalink(); or
$group->getAlias = $user->getAlias();

:/
·
Friday, 14 November 2014 12:12
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

Try $group->alias = $user->alias;
·
Friday, 14 November 2014 12:14
·
0 Likes
·
0 Votes
·
0 Comments
·
I have set my username as: test1
and my permalink is: abcavocats

$user->alias returned test1
which then sets: en/community/groups/item/14-test1.html

I would want to see
en/community/groups/item/14-abcavocats.html

cant seem to have it :/
·
Friday, 14 November 2014 12:31
·
0 Likes
·
0 Votes
·
0 Comments
·
welll... thats very not productive but this works...

$desc = $this->params->get('default');
$data = array('user_id' => $user->id );
$table = Foundry::table('Users');
$table->load($data);

$group = Foundry::table('Cluster');

$group->category_id = 4;
$group->cluster_type = 'group';
$group->creator_type = 'user';
$group->creator_uid = $user->id;
$group->title = &$post['name'];
$group->description = $desc;
$group->alias = $table->permalink;
$group->target_id = $usertoassign;
$group->state = 1;
$group->featured = 1;
$group->type = 3;
$group->parent_id = 0;
$a=JFactory::getDate()->toSql();
$group->created = $a;

$group->store();



$cluster = Foundry::table('ClusterNode');

$cluster->cluster_id = $group->id;
$cluster->uid = $user->id;
$cluster->type = 'user';
$cluster->created = $a;
$cluster->state = 1;
$cluster->owner = 1;
$cluster->admin = 1;
$cluster->invited_by = 0;

$cluster->store();
·
Friday, 14 November 2014 12:59
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi,

I just tested and $user->permalink should work.
·
Friday, 14 November 2014 13:03
·
0 Likes
·
0 Votes
·
0 Comments
·
i tried it and it wasn't working i dunno why but :/ anyway
·
Friday, 14 November 2014 13:18
·
0 Likes
·
0 Votes
·
0 Comments
·
Ok great
·
Friday, 14 November 2014 16:51
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post