Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Display modules on sodi2 results per...
Display modules on sodi2 results per page
Re: Display modules on sodi2 results per page
Yes, it is. What is it you want to do, exactly?
There are some pre-made recipes on this page:
http://www.metamodpro.com/metamod/recip … obi2-pages
If you can explain exactly what you need, I can point you in the right direction.
Cheers,
Stephen
Re: Display modules on sodi2 results per page
Hello Stephen.
I am sorry. I don’t explain very well.
I want to check how many entries I have in a current page of sobi2 listing and display modules.
I want something like that but I don’t know how to get sobi2 results per page:
Code:
if ( $option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'usersListing' and sobi2 results per page == '10')
{
$mods = array();
$mods[] = 116;
$mods[] = 73;
$mods[] = 82;
$mods[] = 38;
return $mods;
}
Re: Display modules on sodi2 results per page
Hi vassilism,
I don't know if the number of results per page is paginated, but I am going to assume for now that it's not paginated. Therefore, this recipe will return the number of items submitted by the current user. You can use this to determine which module(s) to show.
I hope this is what you are after.
Cheers,
Stephen
if ( $option == "com_sobi2" and JRequest::getVar('sobi2Task') == 'usersListing' ) {
$config =& sobi2Config::getInstance();
$database = $config->getDb();
$uid = sobi2Config::request( $_REQUEST, "uid", 0 );
$expired = false;
if( !$uid ) {
$my =& $config->getUser();
$uid = $my->id;
$expired = $config->key("users_own_listing", "can_see_expired");
}
if( !$uid ) {
return;
}
$user =&sobi2bridge::jUser( $database );
$user->load( $uid );
$published = !$config->key("users_own_listing", "can_see_unpublished");
$published = $published ? " AND published = 1 " : null;
$query = "SELECT count(itemid) FROM #__sobi2_item WHERE owner = {$user->id}{$published}";
$database->setQuery($query);
$num_sids = $database->loadResult();
// now $num_sids contains the number of entries for this user.
// replace AAA, BBB, CCC etc with the module ids to return
// if the user has that many entries.
// If the user has less than 10, it will only return module AAA.
// If the user has >=10 and <15, it will only return module BBB, etc.
// If the user has >= 20, it will return the list of module numbers.
if ( $num_sids < 10 ) return AAA;
if ( $num_side < 15 ) return BBB;
if ( $num_side < 20 ) return CCC;
return "116, 73, 82, 38";
}
// if not on the user listing page, return module XXX
return XXX;
Re: Display modules on sodi2 results per page
So can I just confirm a few things with you:
1 - where do you set the number of items in the pagination? I can't seem to find it. (either on admin side or user side)
2 - do you want to detect the number of items of the pagination (e.g. "10" no matter how many items are *actually* being displayed), or do you want the number of items actually being displayed (so if the pagination is 10 but there are only 3 items, you want "3") ?
3 - exactly which pages do you want this for? You mentioned the usersListing page above, but you seem to want others as well. You need to be completely specific about which pages you want to target, as the code for each may be different.
Best regards,
Stephen
Re: Display modules on sodi2 results per page
metamodguy wrote:
1 - where do you set the number of items in the pagination? I can't seem to find it. (either on admin side or user side)
I set the number of items in the pagination at sobi2 backend component.
metamodguy wrote:
2 - or do you want the number of items actually being displayed (so if the pagination is 10 but there are only 3 items, you want "3") ?
I want exactly this.
If the pagination is 10 but there are only 3 items, I want "3".
metamodguy wrote:
3 - exactly which pages do you want this for? You mentioned the usersListing page above, but you seem to want others as well. You need to be completely specific about which pages you want to target, as the code for each may be different.
I want this for sobi2 pages:
Sobi2 listing - file: components/com_sobi2/sobi2.listing.php
Search page - file: components/com_sobi2/axsearch.class.php
User listing - file: components/com_sobi2/includes/custom.listing.php
These are the pages where displaying all sobi2 results on front end.
Thanks for your help
Regards,
Vasilis
Re: Display modules on sodi2 results per page
Vasilis,
would you be happy with adding a couple of lines to a couple of core files in SOBI2? This will make the end result FAR more efficient (i.e. don't have to do extra database queries), and requires a lot less code.
Cheers,
Stephen
Re: Display modules on sodi2 results per page
Ok, we have a bit of a problem with the search: it's done using AJAX (i.e a live search on the page without a full page refresh).
This means that the modules don't get a chance to refresh when you do a search, because there's no full page refresh.
You could make a plugin for the SOBI2 search results ajax script. This would involve making a plugin that has a method named "onAjaxSearchResult". Output from SOBI2 search plugins appears to get inserted at the TOP of the search results, so perhaps that would be enough?
Doing any further work on the search results thing is beyond the scope of MetaMod, sorry, so I'm not going to work on this part of it any further. I'll continue to look at the normal listings however.
Re: Display modules on sodi2 results per page
For the user listing, make the following change in custom.listing.php:
around line 386 you will see the following code:
$requestParams =& $config->get_( "requestParams" );
if( ( $templateFunction && $templateFunction != "sobi2VCview" ) || !$forceCache ) {
$doCache = false;
}
BEFORE that code, put the following line:
$config->set("resultlist_count", isset( $results ) && !empty( $results ) ? count($results) : 0 );
Then in the MetaMod you can use the following code:
if ( $option == "com_sobi2" ) {
$config =& sobi2Config::getInstance();
$num_items = $config->get( "resultlist_count" );
// module XXX if there are more than 5 items showing
if ($num_items > 5) return XXX; // replace XXX with module id to show
}
In the next post I should be able to do something similar for the standard results listings.
- Index
- » MetaMod Pro
- » MetaMod Pro General Support
- » Display modules on sodi2 results per...
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5944
- Posts this week:
- 2
- User Info:
- Total Users:
- 7658
- Newest User:
- carre82601
- Members Online:
- 0
- Guests Online:
- 103
- Online:
- There are no members online
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked