By Alexandre Cayer on Saturday, 28 March 2015
Posted in General Issues
Replies 10
Likes 0
Views 619
Votes 0
Hi guys,

I'm looking to add a "Paid" filter on the sidebar of the default group layout. See that theme should be:

<li class="filter-item<?php echo $filter == 'paid' && !$activeCategory ? ' active' : '';?>" data-es-groups-filters-type="paid">
<a href="/<?php echo FRoute::groups( array( 'filter' => 'paid' ) );?>" title="<?php echo JText::_( 'COM_EASYSOCIAL_PAGE_TITLE_GROUPS_FILTER_PAID' , true );?>" ><?php echo JText::_( 'COM_EASYSOCIAL_GROUPS_PAID' );?></a>
<span class="es-count-no pull-right" data-total-paid><?php echo $totalPaid;?></span>
</li>

i) Where is the method of this view to set totalPaid? view.html.php?
ii) What do I have to do for the group route (filter) to have it work?
iii) Any other thing I should know (corresponding method to adjust?!) in order to have a new group filter base on my paid group value to work? (beside language token)
Hello Alexandre,

I am really sorry for the delay of this reply as it is a weekend for us here. You will need to actually add some hacks in the file /components/com_easysocial/controllers/groups.php to add your new filter in it.
·
Saturday, 28 March 2015 16:51
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,

Just got my hand over the controller file and getGroups method. If I would do :
	if ($filter == 'featured') {
// Get a list of featured groups
$options['featured'] = true;
$featuredGroups = $model->getGroups( $options );
} else {

// Determine the pagination limit
$limit = FD::themes()->getConfig()->get( 'groups_limit' , 20 );
$options[ 'limit' ] = $limit;

if ($filter == 'mine') {
$options['uid'] = FD::user()->id;
$options['types'] = 'all';
}

if ($filter == 'invited') {
$options['invited'] = FD::user()->id;
$options['types'] = 'all';
}

if ($filter == 'paid') {
$options['paid'] = true;
$options['types'] = 'all';
}

if ($categoryId) {
$options['category'] = $categoryId;
}

// Get the groups
$groups = $model->getGroups($options);
}


Will the Method for groups with options "paid" checks for their paid variable ? Or this isn't the proper method to test for one group's variable as per the Method FD is implemented with ?

As usual, thanks, especially on Week-end

Alex
·
Sunday, 29 March 2015 04:44
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Mark,

That one was quite a tricky one... custom mod to: template to add the trigger, view to add the count variable, language for the language token, controller to add the trigger to the method... not working for the group grab... then I look to the group administrator method getGroups and boombed it is databased and not field based :/ I have a group custom field "paid" which is a custom copy of the boolean version. so I basicly check if "paid" is set to true or false. How can I add to the group method an SQL query to test that for a particular field !?!?!
·
Sunday, 29 March 2015 07:32
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Alexandre,

I am really sorry for the delay of this reply as it is a weekend for us here. You can't just add a "filter" to the database layer. You will need to modify the sql queries on the model file to be able to accept the new filter option and extend the SQL queries there.
·
Sunday, 29 March 2015 12:43
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark,

This seems to work on PHPmyAdmin with;

SELECT distinct(a.id) FROM `#__social_clusters` as a
JOIN `#__social_fields` as x ON a.id = x.step_id JOIN `#__social_fields_data` as y ON x.id = y.field_id
where x.unique_key='paid' and y.raw = 0;

However, can't find the equivalent on object call...any idea why this doesn't work ?:

$paid = isset($filter[ ‘paid’ ]) ? $filter[ ‘paid’ ] : '';

if ($paid) {
$sql->join('#__social_fields', 'x', 'INNER');
$sql->on('a.id', 'x.step_id');
$sql->join('#__social_fields_data', 'y', 'INNER');
$sql->on('x.id', 'y.field_id');
$sql->where('x.unique_key','PAID');
$sql->where('y.raw',$paid);
}
·
Sunday, 29 March 2015 14:15
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Mark, I'm mostly sure that the error is in the routing since when i try to reload community/groups/paid.html, it gives me an error:
404 - Sorry, the group id provided is invalid. Please try again.

so my guess is that it never goes into the method and never got query... I tried to put and echo and die into my paid if statement and nothing happens... therefore it never goes into it... hows the routing works for group
·
Sunday, 29 March 2015 14:54
·
0 Likes
·
0 Votes
·
0 Comments
·
Here's my package to add a group filter, I see the console which trigger the error when I press on paid... this is really takin me out of my boots

OMG... first error... coma style on: $paid = isset($filter[ 'paid' ]) ? $filter[ 'paid' ] : '';

Can you believe.... an editor error for the ' ...

EDIT: The SQL now seems to work with:
$paid = isset($filter[ 'paid' ]) ? $filter[ 'paid' ] : '';

if ($paid=='paid') {

$sql->join('#__social_fields', 'x', 'INNER');
$sql->on('a.id', 'x.step_id');
$sql->join('#__social_fields_data', 'y', 'INNER');
$sql->on('x.id', 'y.field_id');
$sql->where('x.unique_key','PAID');
$sql->where('y.raw','1');

}

Unsolved problem: direct load through community/groups/paid.html doesn't work which seems to be a router error

QUESTION 1:
Which file i need to check to resolve that error ? which Method ?

QUESTION 2:
I saw an error log window in screen, which was really useful... how could i use that for my own debug ?

COMMENT 1:
This, as many questions logged in my ES Bible from the last year, would be terrific developper material. The documentation is still lagging and wasn't updated with ES update. I could definitely help around for this as this would also, that I am sure, cut some forum time is the doc is updated properly. I'm sure this would prove useful so as updates of other independant dev like me!
·
Sunday, 29 March 2015 23:19
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Alexandre,

Kindly please do understand that our support does not cover customizations. The reason that you are getting an error is most likely because you did not add a new "filter" criteria in the router's library. See /administrator/components/com_easysocial/includes/router/adapters/groups.php on line 188 onwards.
·
Monday, 30 March 2015 00:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Mark,

Thanks and sorry, if this wasn't be for the editor error, i would have just ask to where the router is. I'm usually well enough to code my own stuff but I though for this one that it was a ES error since i was sure the code was right and the sql query was working. I am perfectly aware that you guys don't cover specific customization and don't want to waste your time with this when I post this type of question! My thpe of intervention resolve either on pointing finger to the proper file or telling you of bug i encounter while i play around the code...

Anyway, thanks again! And you should consider accepting some help for the documentation again i am sure this could help you save time!

Alex
·
Monday, 30 March 2015 01:21
·
0 Likes
·
0 Votes
·
0 Comments
·
You are most welcome Alex If you are willing to chip in some help with the docs, you are always more than welcome
·
Monday, 30 March 2015 01:58
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post