Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 01-08-2011 19:09:44

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Need Some Advice On Modifying catlist, Please...

What changes to I need to make to the catlist function...


Code:

// +------------------------------------------------------------------+
// | Function: catlist                                                |
// +------------------------------------------------------------------+

function catlist ($input = array()) {

// +--
// | This function displays a listing of categories.
// +--

// +--
// | Return immediately if the store is offline.
// +--

if (!($this->store_active(1))) {return 1;}

// +--
// | We need to build an SQL statement here.  We start with our table
// | and columns.
// +--

$table = $this->app . '_cat';

$colstring = $this->KHXC_DB->table_column_string($table);

if (($this->IsError($colstring)) || (empty($colstring))) {return 1;}

$sql = "SELECT {$colstring} FROM $table WHERE ";

$where = '';

// +--
// | Handle visibility.
// +--

$usergroup = $this->globals('khxc_user.usergroup');

if (empty($usergroup)) {

     if (!(empty($where))) {$where .= 'AND ';}     
     $where .= '(catview=' . $this->KHXC_DB->quote('A') . ') ';

} else {

     if (!(empty($where))) {$where .= 'AND ';}  
     $where .= '((catview=' . $this->KHXC_DB->quote('A') . ') OR ';
     $where .= '(catview=' . $this->KHXC_DB->quote('L') . ' AND ';
     $where .= '(catviewg LIKE ' . $this->KHXC_DB->quote_like($usergroup . ',', 'SUFFIX') . ' OR ';
     $where .= 'catviewg LIKE ' . $this->KHXC_DB->quote_like(','  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'catviewg LIKE ' . $this->KHXC_DB->quote_like(', '  . $usergroup, 'PREFIX') . ' OR ';
     $where .= 'catviewg LIKE ' . $this->KHXC_DB->quote_like(','  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'catviewg LIKE ' . $this->KHXC_DB->quote_like(', '  . $usergroup . ',', 'WRAP') . ' OR ';
     $where .= 'catviewg='       . $this->KHXC_DB->quote($usergroup) . '))) ';

} // End of if statement.

// +--
// | Handle the categories we're viewing.  If we have a input
// | array we know we're viewing sub-categories.  Otherwise
// | we've got a splash page access.
// +--

if (empty($input)) {

     if (!(empty($where))) {$where .= 'AND ';}    
     $where .= '(splashdisp=' . $this->KHXC_DB->quote(1) . ') ';

} else {

     if (!(empty($where))) {$where .= 'AND ';}

     $xcat = '(';

     foreach ($input as $num => $cat) {

          $xcat .= 'id=' . $this->KHXC_DB->quote($cat) . ' OR ';

     } // End of foreach statement.

     if (preg_match('/ OR $/',$xcat)) {$xcat = rtrim($xcat,' OR ');}

     $where .= $xcat . ') ';

} // End of if statement.

// +--
// | Piece together our SQL statement and execute it.
// +--

$sql .= $where;

$result = $this->KHXC_DB->sql_do(array('sql'    => $sql,
                                       'table'  => $table,
                                       'order'  => array('sortorder' => 'ASC')));

if ($this->IsError($result)) {return 1;}

if (empty($result)) {

     if ($this->debug) {$this->debugger("catlist: Did not locate any categories to display.  App: {$this->app}");}

     return 1;

} // End of if statement.

if ($this->debug) {$this->debugger("catlist: Completed building and executing SQL.  App: {$this->app}");}

// +--
// | Modify our category image names if the image does not
// | exist.
// +--

     $imgpath = $this->globals('khxc.path_public') . '/media/' . $this->app . '/';

     foreach ($result as $num => $data) {

          if ((empty($result[$num]['catimg'])) || (!(file_exists($imgpath . 'cat/' . $result[$num]['catimg'])))) {
          $result[$num]['catimg'] = 'none.png';

          } // End of if statement.

     } // End of foreach statement.

// +--
// | Globalize the result.
// +--

$this->globals('ecom.cat_catlist',$result);

// +--
// | If we're on the splash page we need to set our display
// | variables.  Otherwise this has already been done in
// | the catshow namespace.
// +--

if (empty($input)) {

     $catnum   = $this->globals('khxc_settings.' . $this->app . '.splashcatnum');
     $cattype  = $this->globals('khxc_settings.' . $this->app . '.splashcattype');

     $this->globals('ecom.cat_catnum',$catnum);

} else {

     $catnum   = $this->globals('ecom.cat_catnum');
     $cattype  = $this->globals('ecom.cat_cattype');

} // End of if statement.

if ($this->debug) {$this->debugger("catlist: Set number of rows to display as '{$catnum}' and display type as '{$cattype}'.  App: {$this->app}");}

// +--
// | Retrieve our catdisp code from the catdisp table.
// +--

$table = $this->app . '_catdisp';

$sql   = "SELECT incdisp FROM {$table} WHERE id=";
$sql  .= $this->KHXC_DB->quote($cattype);

$result = $this->KHXC_DB->sql_do(array('sql'    => $sql,
                                       'table'  => $table,
                                       'order'  => array('id' => 'ASC')));

if ($this->IsError($result)) {return 1;}

// +--
// | If the result is empty we try to retrieve the default.
// +--

if (empty($result)) {

     if ($this->debug) {$this->debugger("catlist: Did not retrieve include code for display type '{$cattype}'.  Trying default.  App: {$this->app}");}

     $sql   = "SELECT incdisp FROM {$table} WHERE id=";
     $sql  .= $this->KHXC_DB->quote('default');

     $result = $this->KHXC_DB->sql_do(array('sql'    => $sql,
                                            'table'  => $table,
                                            'order'  => array('id' => 'ASC')));

     if ($this->IsError($result)) {return 1;}
     if (empty($result)) {return 1;}

} // End of if statement.

// +--
// | Globalize our incdisp and display our category include.
// +--

$this->globals('ecom.cat_incdisp',$result[0]['incdisp']);

if ($this->debug) {$this->debugger("catlist: Displaying the category include.  App: {$this->app}");}

$this->KHXC_Display->include_file($this->app,'catlist.php');

if ($this->debug) {$this->debugger("catlist: Finished category listing.  App: {$this->app}");}

// +--
// | Return true.
// +--

return 1;

} // End of function.

// +------------------------------------------------------------------+
// | End of Class                                               [KHXC]|
// +------------------------------------------------------------------+

} // End of class.

// +------------------------------------------------------------------+
// | End Of File                                                [KHXC]|
// +------------------------------------------------------------------+

?>

...in order to get a list of hyperlinked categories and nothing more?

I have all kinds of workarounds for this basket in place for everyday browsing, but none that are suitable for the display I need at the moment. - I'm guessing that it should be fairly simple, but the store software completely refuses to accept modifications to the  function. - Nothing breaks, - just, quite simply, there are no changes whatsoever, : the modifications have not the slightest effect, short of me ripping chunks out of the code (so I know I am definitely not working on the wrong file! wink ).  Can anyone help with this, please?

Last edited by Design_Wholesale (01-08-2011 19:10:39)

Offline

 

#2 01-09-2011 08:00:01

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Need Some Advice On Modifying catlist, Please...

All that function is doing is building and setting up global variables for use by the category display include, which resides in the database, and the catlist.php include which you can see being included near the end of what you posted.

The actual category links are created in the display include from the database using the following line:

Code:

$catlink  = $this->link_namespace($app,'catshow',$catdisp['id']);

Offline

 

#3 01-09-2011 15:52:17

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Need Some Advice On Modifying catlist, Please...

Thanks, but that is not referenced in  and does nothing on its own.

I think the best way of doing this is going to be to simply use a new namespace/webpage combination. - Messy, but there is simply absolutely no decent documentation on making this kind of thing work with the store software and I could mess with that all month (already taken six months) and not get anywhere. - Not your fault, - just a serious oversight on the development side of things which requires that any serious modification of the software involves the store owner being a PHP guru, like yourself.

Last edited by Design_Wholesale (01-09-2011 15:53:18)

Offline

 

#4 01-09-2011 16:01:14

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Need Some Advice On Modifying catlist, Please...

I didn't say it was in GBU_Cat and it isn't. It's in the include for displaying categories though it could be used anywhere. It isn't really clear from your original post what you're trying to do or where so I gave you the best pointer I could based on the information supplied.

Offline

 

#5 01-09-2011 16:24:29

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Need Some Advice On Modifying catlist, Please...

That's okay, - I appreciate it and have noted that snippet for further study and experimentation.

In the meantime the following code, placed in a new page, works for what I need, although it might need some slight aesthetic work:

Code:

<?php 

$ref                = $this->globals('khxc.ref');
$ns               = $this->globals('khxc.namespace');
$prodidx          = $this->globals('ecom.prod_prodidx');
$dispapp           = $this->globals('khxc_display.app');
$app               = $this->globals('khxc.app');
$eol               = $this->globals('khxc.eol');
$proddisp          = $this->globals('ecom.prod_proddetail');
$prodnum           = $proddisp['prodnum'];

include '/database_details.php';

print '<table>

<tr>';

mysql_connect("$s", "$u", "$p") or die(mysql_error());
mysql_select_db("$d") or die(mysql_error());

$result = mysql_query("SELECT DISTINCT id,name FROM gbu0_cat order by id" ) or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
print '<td style="border: 0; padding: 25px 0 0 0; vertical-align: top;"><a href="/gbu0-catshow/' . $row['id'] . '.html" alt="' . $row['name'] . '" />' . $row['name'] . '</a><br /></td></tr><tr>';
}

print '<td>&nbsp;</td></tr></table>';


?>

Last edited by Design_Wholesale (01-09-2011 16:32:23)

Offline

 

#6 01-09-2011 16:44:00

Dave
Member
Registered: 07-05-2003
Posts: 11233

Re: Need Some Advice On Modifying catlist, Please...

That's pretty much a very stripped down version of the "Category List Display" XHTML include that I alluded to earlier smile

Offline

 

#7 01-09-2011 17:00:20

Design_Wholesale
Member
From: England!
Registered: 11-21-2008
Posts: 1104
Website

Re: Need Some Advice On Modifying catlist, Please...

Fair enough, - I am really struggling to make sense of why allot of the code that is present in the likes of  is there, especially on the MySQL side of things, but what I was originally hoping to do was to simply knock a few bits out in order to generate that that the code shown above generates and, yes, your code would have produced something similar - I was simply confused because it was presented as though it should have been something for use on its own or something in the  code that could have been edited.

I now have a nice clean catlist presentation for mobile browsing (with working hyperlinks smile ), though, and that's the main thing. - Thank-you.

Last edited by Design_Wholesale (01-09-2011 17:01:06)

Offline

 

Board footer