Zen Cart Logo
Forums / General Questions / Questions related to functions

Questions related to functions

Locked

Views: 1,289

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
10 Aug 2006, 6:45 PM
#1
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Questions related to functions

Ok So I was trying to understand this function:
zen_parse_search_string
which parses search string into indivual objects
It accepts two parameters
zen_parse_search_string($search_str = '', &$objects)
I am not able to understand what second parameter is

When it is getting called in header_php.php, it is getting called as:
zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords))
although I can understand how first parameter is coming, but I am not able to understand from where the value of $search_keywords is coming from

I tried the search and got this url:
http://localhost/zencart/index.php?main_page=advanced_search_result&search_in_description=1&zenid=147a2eef38fccd6143ec56ba12ed1023&keyword=microsoft

So value of $_GET['keyword']='microsoft' but what is &$objects?
Please explain with an example
Thanks

11 Aug 2006, 10:00 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Questions related to functions

The & indicates that the stated object is being passed by reference.
It's an OOP technique.
This article may help: http://www.zend.com/php5/articles/engine2-php-oo.php

12 Aug 2006, 4:34 AM
#3
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Questions related to functions

Thanks
I cannot get where $search_keywords is getting the value from
Is it empty?
San

12 Aug 2006, 6:18 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Questions related to functions

$search_keywords is set within the function, and its contents are available to the script after the function returns from execution

  if (zen_parse_search_string(stripslashes($_GET['keyword']), $search_keywords)) {
  1. run the function, passing the $_GET info for 'keyword' param, also passing the variable into which calculated search keywords will be placed
  2. when the function is completed, it returns a boolean true/false, and at the same time, $search_keywords has the contents of the stated object in the function ... in this case, the $objects array, which is the prepared search wordslist.
14 Aug 2006, 6:21 PM
#5
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Questions related to functions

Is there any documentation as to which file do what etc?

Let us say, for instance
I want to make changes in the search functionality
How can I do this?
This and lot more questions keep going on my mind as to how zen cart works
I know it will come with experience and I am reading and trying to understand the functions/classes of zen cart but again just wanted to ask the people here if there is any documentation which can make my task easier
Thanks

17 Aug 2006, 1:13 AM
#6
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Questions related to functions

Can somenoe tell me how the new version works
just a small example would do
I dont see main_page calling advanced_search_result in application_top
What changes have happened in the latest version?
Thanks
San

17 Aug 2006, 1:53 AM
#8
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Questions related to functions

Thanks

Just to capture the variables, I added this piece of code in

includes\templates\template_default\sideboxes\tpl_search_header.php

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $content;
fwrite($fh, $stringData);
fclose($fh);

It works seperately(file gets created with values written in it)
But not when I am trying to run it here inside tpl_search_header.php
Any idea why?

updates: Its working I was not seeing the file in the correct path!

19 Aug 2006, 10:49 PM
#9
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Questions related to functions

In the file functions\general.php

function zen_validate_password($plain, $encrypted) {
if (zen_not_null($plain) && zen_not_null($encrypted)) {
$stack = explode(':', $encrypted);
if (sizeof($stack) != 2) return false;
if (md5($stack[1] . $plain) == $stack[0]) {
return true;
}
}
return false;
}

When I passed the password string as 'zencart123' and I did

echo (md5($stack[1]).$plain);

I dont get my output as zencart123 although it gets validated and function is returning true

6 Dec 2006, 12:01 PM
#10
paulm avatar

paulm

Totally Zenned

Join Date:
Nov 2003
Posts:
1,878
Plugin Contributions:
5

Re: Questions related to functions

DrByte:

The & indicates that the stated object is being passed by reference.
It's an OOP technique.
This article may help: http://www.zend.com/php5/articles/engine2-php-oo.phpVery interesting article DrByte, thanks for posting the link :-)