Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Paginate two different modules on same page with one query?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
vladimir
Smarty Rookie


Joined: 27 Sep 2007
Posts: 7

PostPosted: Fri Oct 05, 2007 11:57 am    Post subject: Paginate two different modules on same page with one query? Reply with quote

Hello,
i am using Smarty Paginate, and faced a problem.

On my page, depends on the menuID, i am calling one or more 'modules' for that menu(page).
Each module have a tpl file.
eg. when in current menu i have 3 modules, one called news module, and two called Info modul, i call 2 tpl files, one for news module and 1 for Info modul.
Modules can be on the left, center or right panel on the page.

also, Info module can be set to show only Title or Short Description, or Picture and Long Descriptio, or all of them, depending of your needs.

Now the problem:
When i have only 1 Info modul on the page, smarty paginate works good for me. If there is a more then 1, i got paginate same for all modules on page.

How i can made Smarty paginate to display results for each module separately? I would like to mention that module can be same type, on the same page part, or in different page part(left, right, center)

Pls, give me some direction how to do this, it is very important for my current position at job Sad

There is my sql query:

Code:

$sql1 = "SELECT ModuleID FROM modules where TabID = '$menuID' and ModuleDefID='14'";//looking for module id on current page
         $res1 = $conn->Execute($sql1);
         while($row1 = $res1->FetchRow()){
            $moduleID = $row1['ModuleID'];
            $findPane = "select PaneName from modules where  ModuleID = '$moduleID' and TabID = '$menuID' and ModuleDefID='14'";//looking for position on page(left, right or central pane)
            $rezfindpane = $conn->Execute($findPane);
            while($pane = $rezfindpane->FetchRow()){
               $paneName=$pane['PaneName'];//could be RightPane, CentralPane or LeftPane
            }
            $sql2 = "SELECT brojRezultata, listing from modules where ModuleID = '$moduleID'";//looking for how many results to display for this modul, and what to display. Field 'listing' could have different values for every modul(ShortDescription, LongDescription, Title...)
            $res2 = $conn->Execute($sql2);
            $row2 = $res2->FetchRow();
            $numResult = $row2['brojRezultata'];//this is number of results to show
            if(!empty($row2['listing'])){$listing = $row2['listing'];} else {$listing="title,longDesc";}//$listing eg. title,longDes,picture
            $_query1 = sprintf("SELECT SQL_CALC_FOUND_ROWS
                  contentID, moduleID, keywords, description, $listing, picture, metaTitle, 
                  createDate,createBy, archiveDate, archivedBy,menuID, langID,sticky, articleOrder,
                  archived, editedBy, editedDate, tokeni FROM content where menuID = '$menuID'
                  AND moduleID ='$moduleID' and langID = '$langID' AND sticky != '1'
                  AND archived='0' and targetGroups like'%".$_SESSION['q']."%'  order by articleOrder
                  LIMIT %d,%d",SmartyPaginate::getCurrentIndex(), $numResult);
            $_result1 = $conn->Execute($_query1);
            while ($_row1 = $_result1->FetchRow()) {
               $smarty->append('listContent_'.$paneName,$_row1);//here i list data for Info modul, which i use in my listArticles.tpl
            }
            $_data[] = $_row1;
            $_data = range(1,$t);
            $paneName=explode(',',$moduleID);
            foreach ($paneName as $paneName) {
               $_query1 = "SELECT FOUND_ROWS() as total";
               $_result1 = mysql_query($_query1);
               $_row1 = mysql_fetch_array($_result1, MYSQL_ASSOC);
               $t=$_row1['total'];
               SmartyPaginate::setTotal($t,$moduleID);
            }
         }
                  return array_slice($_data, SmartyPaginate::getCurrentIndex($moduleID),SmartyPaginate::getLimit());


changes i made in SmartyPaginate::setTotal are result of my desperatency :/
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Fri Oct 05, 2007 1:31 pm    Post subject: Reply with quote

You can setup three separate "forms" for SmartyPaginate, just give them all unique names. Be sure to use the proper form name for each SmartyValidate function call, and each template function.
Back to top
View user's profile Send private message Visit poster's website
vladimir
Smarty Rookie


Joined: 27 Sep 2007
Posts: 7

PostPosted: Mon Oct 08, 2007 8:40 am    Post subject: Reply with quote

huh Mohrt, i didn't understand what you mean... Sad
I dont have any Form on the page.
Just results from table.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Oct 08, 2007 3:06 pm    Post subject: Reply with quote

Sorry, I had my head in SmartyValidate Smile

You can set an ID for each instance of SmartyPaginate you want to instantiate. Use a separate instance for each pagination you want, then use the proper ID to call the correct instance. The README documentation shows how to use ID for each function call.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP