1
Wheeler
Alphabetical Order Bugfix
  • 2005/3/8 4:32

  • Wheeler

  • Not too shy to talk

  • Posts: 145

  • Since: 2004/10/29


The alphabet menu (I believe it is by catzwolf from WF-Projects Team) has had some problems reported recently. I think I have found a solution. I have tested it on WF-Downloads and it seems to work fine.

Please give code suggestions and feedback for I am a beginner php programmer, if that.

Alphabet menu fix: display current letter on page and 'Next page' works while listing by alphabetical order.

New Template Smarty Tags: <{$letter_sortby}> to display the currently sorted letter.

Add this code to viewcat.php
Quote:

include 'header.php';
include_once XOOPS_ROOT_PATH . '/class/xoopstree.php';

global $xoopsModuleConfig, $myts, $xoopsModules;

$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$orderby = isset($_GET['orderby']) ? convertorderbyin($_GET['orderby']) : $xoopsModuleConfig['filexorder'];
$cid = (isset($_GET['cid']) && $_GET['cid'] > 0) ? $_GET['cid'] : 0;
$list = isset($_GET['list']) ? $_GET['list'] : 0; // Added by Wheeler

----- Search down page -----

/**
* Breadcrumb
*/
$mytree = new XoopsTree($xoopsDB->prefix('xxxxx_cat'), "cid", "pid");
$pathstring = "" . _MD_XXX_MAIN . " : ";
$pathstring .= $mytree->getNicePathFromId($cid, "title", "viewcat.php?op=");
$xoopsTpl->assign('category_path', $pathstring);
$xoopsTpl->assign('category_id', $cid);
$xoopsTpl -> assign('letter_sortby' , $list); // Added by Wheeler
$arr = $mytree->getFirstChild($cid, "weight");

----- Search down page -----

/**
* Extract Download information from database
*/
$xoopsTpl->assign('show_categort_title', true);
$sql = "SELECT * FROM " . $xoopsDB->prefix('xxxxx_downloads') . " ";
if (isset($_GET['selectdate']))
{
$sql .= "WHERE TO_DAYS(FROM_UNIXTIME(published)) = TO_DAYS(FROM_UNIXTIME(" . $_GET['selectdate'] . "))
AND published > 0 AND published <= " . time() . " AND (expired = 0 OR expired > " . time() . ")
AND offline = 0 ORDER BY published DESC";
$result = $xoopsDB->query($sql, $xoopsModuleConfig['perpage'] , $start);
$total_numrows['count'] = $xoopsDB->getRowsNum($xoopsDB->query($sql));
} elseif (isset($_GET['list']))
{
$sql .= "WHERE title LIKE '" . $_GET['list'] . "%' AND published > 0 AND
published <= " . time() . " AND (expired = 0 OR expired > " . time() . ") AND offline = 0
ORDER BY " . $orderby;
$result = $xoopsDB->query($sql, $xoopsModuleConfig['perpage'] , $start);
$total_numrows['count'] = $xoopsDB->getRowsNum($xoopsDB->query($sql)); // Added by Wheeler
}
else
{
$sql .= "WHERE cid=" . $cid . " AND published > 0 AND published <= " . time() . "
AND (expired = 0 OR expired > " . time() . ") AND offline = 0
ORDER BY " . $orderby;
$result = $xoopsDB->query($sql, $xoopsModuleConfig['perpage'] , $start);
$xoopsTpl->assign('show_categort_title', false);
$total_numrows = xxx_getTotalItems($cid);
}

----- Search down page -----

/**
* Nav page render
*/
include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
if (isset($_GET['selectdate']))
{
$pagenav = new XoopsPageNav($total_numrows['count'], $xoopsModuleConfig['perpage'] , $start, 'start', 'list=' . $_GET['selectdate']);
}
else if ($list) // Added by Wheeler
{
$pagenav = new XoopsPageNav($total_numrows['count'], $xoopsModuleConfig['perpage'] , $start, 'start', 'list=' . $list); // Added by Wheeler
}

else
{
$pagenav = new XoopsPageNav($total_numrows['count'], $xoopsModuleConfig['perpage'] , $start, 'start', 'cid=' . $cid);
}
$page_nav = $pagenav->renderNav();
$istrue = (isset($page_nav) && !empty($page_nav)) ? true : false;
$xoopsTpl->assign('page_nav', $istrue);
$xoopsTpl->assign('pagenav', $page_nav);
}


Hmmm? I hope this code displays properly.

Let me know what you think!?

2
Wheeler
Re: Alphabetical Order Bugfix
  • 2005/3/8 4:44

  • Wheeler

  • Not too shy to talk

  • Posts: 145

  • Since: 2004/10/29


I also hope I recorded each code added or changed properly, maybe some code not displayed in blue. I started without keeping track of modifications, then went back looking for it. Sorry.

Other features done? To be submitted to the WF-Projects Team for their future releases...

-rated and reviewed averages by number (eg. 7.66), image display still works, may use both.

-added a new scoring system using number of downloads, votes, and reviews, combined with rated and reviewed averages.

-Added path to display for download items list, instead of just the (sub)category which the download item belongs to.

-Added functionality, display categories and download items while group access set to no, instead of completely hiding them.

-Email bug fixes, There are more than just the one 'Email a Friend' bug.

-Template work:
---Never get a 'You don't have permission to access' message again.
---Logical display message for 'no downloads added to (category OR letter) listing.'

3
Wheeler
Re: Alphabetical Order Bugfix
  • 2005/3/8 6:36

  • Wheeler

  • Not too shy to talk

  • Posts: 145

  • Since: 2004/10/29


By the way I have the category 'sort by' feature currently disabled. I wonder if using 'sort by' would affect the
<{$letter_sortby}>
and display the current $list value. Could be called
<{$sorted_by}>
Quote:
$xoopsTpl -> assign('letter_sortby' , $list); // Added by Wheeler

to
Quote:
$xoopsTpl -> assign('sorted_by' , $list); // Added by Wheeler


Does anybody else have similar problems with 'sort by' as they do with 'Alphabet Links'?

4
Mithrandir
Re: Alphabetical Order Bugfix

$result $xoopsDB->query($sql$xoopsModuleConfig['perpage'] , $start);
$total_numrows['count'] = $xoopsDB->getRowsNum($xoopsDB->query($sql)); // Added by Wheeler


You already have the $result, so no need to run the query again

Instead use this:
$result $xoopsDB->query($sql$xoopsModuleConfig['perpage'] , $start);
$total_numrows['count'] = $xoopsDB->getRowsNum($result); // Added by Wheeler, optimised by Mith ;-)

5
tzvook
Re: Alphabetical Order Bugfix
  • 2005/3/8 13:16

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


Wheeler

I Don't see anything that is helping with the alphabetic sorting for the letters() function.
I don;t use it @ the MyDownloads mudule, I use it @ the Xdir + the Myedito + Xdir hacked to a phonebook, If you want me to... I can send you the whole module to look @ ... It seems to come from the direction of -
$rankings[$e]['title']


I hoped to implement it @ the MyEdito - so it more or less "close" my requirements from a "homepages" module, so If you want to take a look at a hacked Xdirectory with the "letters()" you might find the problem ...
http://www.meant4u.com/xdirectory.zip

Mith, I would have ask you too, but I'm sure you're loaded with code to go over

Anyway, it might be a really small thing we missed here, and then it'll be easy to add to a lot of mudules, so it's worth the try.

6
Wheeler
Re: Alphabetical Order Bugfix
  • 2005/3/8 17:16

  • Wheeler

  • Not too shy to talk

  • Posts: 145

  • Since: 2004/10/29


hey thanks Mith, it's so obvious lol.

tzvook,
from recent threads, I am aware you have a hacked version of xdir. I also thought I read somewhere your alpha links hack came from WF-Downloads. Sorry, I guess I can not help you. This is beyond the focus of the work which I'm currently conducting.

The code I have should fix the alphabetical listings when the 'pagenav' is used. If your ordered listings carries over to the next page you are okay.

7
tzvook
Re: Alphabetical Order Bugfix
  • 2005/3/9 10:45

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


Quote:

Wheeler wrote:
tzvook,
from recent threads, I am aware you have a hacked version of xdir. I also thought I read somewhere your alpha links hack came from WF-Downloads. Sorry, I guess I can not help you. This is beyond the focus of the work which I'm currently conducting.


No problem Wheeler, but it's not about the XDIR (or the hacked version) ... it's about the "alphabetic links hack" which I thought might be connected to a lot of modules for Alpha sorting if needed.... due to the ease that it can be connected (when fixed).

Actually, I need the hack for the MyEdito module, I linked the Xdir just for alpha-menu test purpose.

Quite funny was for me to find out that all the phonebooks are without an Alphabetic sorting (simply useless) or the business directories (Xdir and so..) That's why I try to find something that'll fit all modules or at least quite a few, hope someone will help.

I'm still trying to find the problem, though quite lost with it... If somebody knows about an Alphabetic menu for sorting the database, please post here...

8
Wheeler
Re: Alphabetical Order Bugfix
  • 2005/3/10 1:37

  • Wheeler

  • Not too shy to talk

  • Posts: 145

  • Since: 2004/10/29


Yes, these type of modules do seem a little useless. In time, when I get my business directory up, I will have a go at it.

Login

Who's Online

425 user(s) are online (328 user(s) are browsing Support Forums)


Members: 0


Guests: 425


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits