Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Display modules on sodi2 results per page

Re: Display modules on sodi2 results per page

Ok, here's what you have to do for the general listings.

Edit the file frontend.class.php

Look for the following lines, around the line 526:

if(!$pluginsMod) {
  $config->sobiCache->add( "listingOnCat_{$catid}_{$this->limitstart}",$results,"listing");
}

AFTER those 3 lines, add the following lines:

$requestParams =& $config->get_( "requestParams" ); // EDITED
$config->sobiCache->addContent( count( $results ) . ".0", $requestParams, "listingOnCat_{$catid}_{$this->limitstart}" ); // EDITED


The ".0" thing is a trick to make the cache accept very short strings, as it has a minimum of 2 characters.


Then in MetaMod you can do this:

if ( $option == "com_sobi2" ) {
  $config                     =& sobi2Config::getInstance();

  $catid = JRequest::getInt("catid",0);
  $limitstart = JRequest::getInt("limitstart",0);
  $requestParams =& $config->get_( "requestParams" );

  $num_items = (int)$config->sobiCache->getContent($requestParams,"listingOnCat_{$catid}_{$limitstart}");

  if ($num_items > 5) return XXX; // replace XXX with module id to show
}



SUMMARY
It was very hard to find the best approach for this and to work around the SOBI2 code. I regret having to hack SOBI2, but in the end it was far easier and more efficient to do this than to have to recreate all the searches in MetaMod, just to be able to get the number of paginated search results!

I would not normally go to these lengths for a request in the forums... it took a few hours of valuable time.

However, I hope that this now works and was worth it for you!

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Display modules on sodi2 results per page

Hello Stephen.
Thank you very much for your time. I appreciate that.

I am sorry but your solution doesn’t working for me.
In file frontend.class.php I don’t have this line:
if(!$pluginsMod) {
  $config->sobiCache->add( "listingOnCat_{$catid}_{$this->limitstart}",$results,"listing");
}
I tested with your code but not working.

I write some custom code in sodi2 core and I have the number of entries per page.
Here is the code:

Code:

$fromResult = $limitstart + 1;            

if ($limitstart + $showlimit < $totalStr) {
$toResult = $limitstart + $showlimit;
} else {
$toResult = $totalStr;
}
$ResultsPerPage = $toResult-$fromResult+1;

In variable $ResultsPerPage I have the number of entries per page but I don’t know how to get this number with metamod pro.

vassilism
Beginner Modder
ranks
useravatar
Offline
8 Posts
User info in posts
Administrator has disabled public posting

Re: Display modules on sodi2 results per page

The problem with your code is that it's unlikely to work when caching is enabled. Even if you can get the ResultsPerPage variable picked up by MetaMod (which you can do with a global or a constant), it may get completely bypassed when you have SOBI caching enabled.

I'm surprised that your code didn't have the same lines in it that mine has. Mine is not completely up to date so perhaps that's the problem.

These are the lines leading up to the ones that I quoted. Perhaps these will help?

Code:

if($this->totalResults) {

    /*
     * if listing should be shown on front page get all published items
     */
    if($catid == 0 && $config->showListingOnFp) {
        $config->listingOrdering = str_replace("relation.","",$config->listingOrdering);
        $query = "SELECT itemid, title, owner, image, icon, background
FROM `#__sobi2_item` AS items " .
                 "WHERE (`published` = 1 AND (`publish_down` > '{$now}'
OR `publish_down` = '{$config->nullDate}' ) AND items.itemid IN({$ids}) )
ORDER BY {$config->listingOrdering} {$limits}";
    }
    else if( $catid != 0 ) {
    /*
     * if show listing in category
     */
    $query = "SELECT DISTINCT relation.itemid,
title, owner, image, background,
icon FROM `#__sobi2_cat_items_relations` AS relation " .
    "LEFT JOIN `#__sobi2_item` AS items ON relation.itemid = items.itemid " .
    "WHERE ((`catid` = {$catid} {$or}) AND `published` = '1' AND (`publish_down` >
'{$now}' OR `publish_down` = '{$config->nullDate}' )
AND items.itemid IN({$ids})
) ORDER BY {$config->listingOrdering} {$limits}";

    }
    $database->setQuery($query);
    $results = $database->loadObjectList();
    if ($database->getErrorNum()) {
        trigger_error("frontend::buildListing(): DB reports: "
        . $database->stderr(), E_USER_WARNING);
    }
    if(!$pluginsMod) {
        $config->sobiCache->add(
            "listingOnCat_{$catid}_{$this->limitstart}",
            $results,"listing");
    }

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Display modules on sodi2 results per page

Hello Stephen.
Yes this code helps me and I find the right place to post your code.
I have disabled my sobi cashe.

Now works perfect but this is work only in sobi2 listing.
It is possible to work in usersListing and sobi search?

vassilism
Beginner Modder
ranks
useravatar
Offline
8 Posts
User info in posts
Administrator has disabled public posting

Re: Display modules on sodi2 results per page

I am sorry. I don’t see your answer with search.

I have modified my sobi search and I have full page refresh.
Here is a link with search results from my website:
http://www.aggelia.eu/index.php?sobi2Se … ;Itemid=62

vassilism
Beginner Modder
ranks
useravatar
Offline
8 Posts
User info in posts
Administrator has disabled public posting

Re: Display modules on sodi2 results per page

Hello Stephen.
I lost some of your posts and now I see your solution with userlisting.
Your solution is great and you use a little bit of code! You are a great developer!
Thank you very much for your time.
Sobi listings and userlisting works perfect!

I only need a solution for sobi search to finish my website.
I have modified my sobi search file and I have full page refresh.
Also I have the number of results per page in search file.
If you like I can attach you my sobi search file.

Now it is possible for a solution in sobi search?

vassilism
Beginner Modder
ranks
useravatar
Offline
8 Posts
User info in posts
Administrator has disabled public posting

Re: Display modules on sodi2 results per page

Ok, looking at this again now... stay tuned.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1686
Total Polls:
6
Total Posts:
5939
Dormant:
User Info:
 
Total Users:
6046
Newest User:
estaglobal
Members Online:
0
Guests Online:
146

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