Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Dynamic DHTML Category Menu


Guest

Recommended Posts

Greetings all.

 

I have just completed a dynamic DHTML Category menu for OSC header.

 

Im looking for a copule of people to test the install before I upload to contributions.

 

If you want to see the menu in action visit http://www.cralyn.com

 

Im also looking for someone to help with some of the coding for this menu to allow configuration values to be set in admin.

 

Enjoy.

Link to comment
Share on other sites

send me the file by email, read your hotmail account ;)

 

and i will help you to add it into the admin area

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

I checked it out. It looks very good. I think it will help if you included ">"

for each menu item. It helps the user know whenever there is a nested or 2nd level sub-category.

 

Just a thought

 

Curious George

Curiousity kills the cat but not George ;-).

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

I'm just trying this out....any idea how to make it look right in Netscape? Is it just a css issue? There are blank spots in the menu items.

 

cheers,

jeff

Link to comment
Share on other sites

  • 4 weeks later...

i'm have'n problems with it being OVERLAPPED by title image in my header( i placed it on top of the page , not under the title image) anyone have any troubles with this????

 

 

-please help it's makeing a cool site look pretty lame :[

- I NOW KNOW THAT I KNOW MUCH LESS THAN I THOUGHT I ONCE DID.

 

 

 

Link to comment
Share on other sites

  • 4 weeks later...

Does anyone know of a way to make this menu default back to the original when a browser with Java disabled is used?

 

I was thinking something along the lines of this sort of code:

<script>

<?php include 'dhtml_menu.php'; ?>

</script>

<noscript>

<?php include 'stnd_menu.php'; ?>

</noscript>

 

Though it didn't work... I think due to the include not working properly inside the <noscript> tags...

 

Any help is appreciated... would also be a good addition to the contribution.

 

Thanks,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

I have it set-up. You can view it here if you like:

www.turningbase.com

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

  • 2 weeks later...

Does anyone know how to detect if JavaScript is enable with php?

What I'm trying to do is load the DHTML menu when JavaScript is enabled, and default back to the original menu when it's not.

 

I've tried the following to test, though it's not working as I thought it would.

<SCRIPT LANGUAGE="JavaScript">

<?php

define (JAVAON,'Yes');

define (JAVAOFF,'No');

?>

</script>

<noscript>

<?php

define (JAVAON,'No');

define (JAVAOFF,'Yes');

?>

</noscript>

<?php echo '<b>Java On?</B> '. JAVAON .'<BR>'. '<b>Java Off? </b>'. JAVAOFF; ?>

 

Can anyone shed some light on this for me?

 

Thanks,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

Hi Tony,

 

I did not need this functionality but I think I will use it to the extend as using javascript can help caching site contents if a script is used to display some content to the user.

 

First the reason that your attempt failed:

 

PHP is only parsed on the serverside whereas javascript as you use it for the menu is client side parsed only. The fact that a browser submits also the mime type "text/javascript" accompanied with the file extension ".js" does not mean that the user allows the execution javascript. On the other hand do the MS internet explorers not send such mime type accept lists upon page refresh.

 

Hence the server will never know if the client will execute any javascript. So th eonly way to find out if javascript will be executed is to attempt using javscript.

 

To do that I added follwing in the head section of a php file.

...

<head>

...

 <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>" />

 <link rel="stylesheet" type="text/css" href="/styles/common.css" />

<?php

if ($javascript == 'on') {

?>

<!--

add here the stuff to be executed if we detected javascript to be executed 

//-->

<?php

} else {

?>

<script language="JavaScript">

<!--

window.location.href =  document.URL + ((document.URL.match(/[?]/))? '&' : '?') + 'javascript=on';

//-->

</script> 

<?php

}

?>

</head>

<body>

...

The other part I've put into application_top.php.

Between the blocks "// Create the cart & Fix the cart if necesary" and "// include currencies class and create an instance" I've added the following:

// rb 20030803 13:00 JAVASCRIPT ON/OFF

 if (!tep_session_is_registered('javascript')) {

   tep_session_register('javascript');

 }

 if (isset($HTTP_GET_VARS['javascript']) || isset($HTTP_GET_VARS['javascript'])) {

 $javascript = ((isset($HTTP_GET_VARS['javascript']) == 'on') || ( isset($HTTP_GET_VARS['javascript']) == 'on'))? 'on' : 'off'; 

 }

// END JAVASCRIPT ON/OFF

But as a side note I'd like to remember everyone who wants to use this that users get quite quick angry if javascript is abused.

If the user decides to disable javascript during the session the server has no way of determining that javascript has been disabled. So don't use javascript for popups and popunders and such annoying stuff. (yeah I know that I am a bit "old fashioned") :-)

 

Anyway, I hope this helps to built better websites. Enjoy :-)

 

regards

 

Ralf

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

short correction

the lines

if (isset($HTTP_GET_VARS['javascript']) || isset($HTTP_GET_VARS['javascript'])) { 

     $javascript = ((isset($HTTP_GET_VARS['javascript']) == 'on') || ( isset($HTTP_GET_VARS['javascript']) == 'on'))? 'on' : 'off'

should actually be

if (isset($HTTP_GET_VARS['javascript']) || isset($HTTP_POST_VARS['javascript'])) { 

     $javascript = ((isset($HTTP_GET_VARS['javascript']) == 'on') || ( isset($HTTP_POST_VARS['javascript']) == 'on'))? 'on' : 'off'

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

Ralf,

THANKS SO MUCH for the code!

I've got it working, you can see it here: www.turningbase.com

 

I know this is a long shot and you probably would have done it if possible, but is there any chance of getting rid of the 'javascript=on' form the URI?

I know I can rename it to DHTMLMENU=on or something like that, but I'd rather nothing in the URI if possible.

 

Once again, THANK YOU for the code... :D

 

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

<?php

if ($javascript == 'on') {

?>

/* your script goes here */

<?php

} else {

?>

<form id="jstest" action="<?php echo $PHP_SELF; ?>" method="post"><input type="hidden" name="javascript" value="on" /></form>

<script language="JavaScript">

<!--

document.getElementsByName('jstest').submit();

/* window.location.href = document.URL + ((document.URL.match(/[?]/))? '&' : '?') + 'javascript=on';*/

//-->

</script> 

<?php

}

?>

compare this to the previous version in the head section of the other files, I hope it works for you. Normally a form element must not be in the head section but you could go around that if you'd say for example

<head>

<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />

<title>Oktoberfest Shop</title>

<meta name="keywords" content="Oktoberfest 2003, oktoberfest.de, oktoberfest-shop, Wiesn-Artikel, Wiesn, Wisn-Haferl, Wiesn-Truck, Oktoberfest-Truck, München 2003" />

<meta name="description" content="Willkommen im offiziellen Oktoberfest-Shop. Hier bekommen Sie die original Oktoberfest-Artikel zum Oktoberfest 2003." />

<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>" />

<link rel="stylesheet" type="text/css" href="/styles/common.css" />

<?php

if ($javascript == 'on') {

?>

/* your script goes here */

</head>

<body>

<?php

} else {

?>

</head>

<body>

<form id="jstest" action="<?php echo $PHP_SELF; ?>" method="post"><input type="hidden" name="javascript" value="on" /></form>

<script language="JavaScript">

<!--

document.getElementsByName('jstest').submit();

//-->

</script> 

<?php

}

?>

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

Ok, I admit, I am no JavaScript Guru (but hey still willing to learn, dunno why Netscape croaks on that but who cares, here s another way to do it).

 

I moved my little code modification a bit down in application_top in order of being able to use 'general.php' and 'html_output.php'

// include the language translations

 require(DIR_WS_LANGUAGES . $language . '.php');



// define our general functions used application-wide

 require(DIR_WS_FUNCTIONS . 'general.php');

 require(DIR_WS_FUNCTIONS . 'html_output.php');



////////////////////////////////////////////////

// rb 20030803 13:00 JAVASCRIPT DETECTION

 if (!tep_session_is_registered('javascript')) {

   tep_session_register('javascript');

 }

 if (isset($HTTP_GET_VARS['javascript']) || isset($HTTP_POST_VARS['javascript'])) {



 $javascript = ((isset($HTTP_GET_VARS['javascript']) == 'on') || ( isset($HTTP_POST_VARS['javascript']) == 'on'))? 'on' : 'off';

 unset($HTTP_GET_VARS['javascript']);

 unset($HTTP_POST_VARS['javascript']);

 $parameters = array('action', 'cPath', 'products_id', 'pid'); 

	 tep_redirect(tep_href_link($PHP_SELF, tep_get_all_get_params($parameters)));

 }

// END JAVASCRIPT DETECTION

////////////////////////////////////////////////  





// currency

and the javascript will still use the get method and not post a form.

	<link rel="stylesheet" type="text/css" href="/styles/common.css" />

<?php

if ($javascript == 'on') {



?>



<?php

} else {

?>

<script language="JavaScript">

<!--

window.location.href = document.URL + ((document.URL.match(/[?]/))? '&' : '?') + 'javascript=on';

//-->

</script> 

<?php

}

?>

</head>

<body>

I personally would like to see the solution with the form to work as well but that might take a while and is not urgent now, but as I see it it can be used to allow users later on to enable or disable javascript use in their "preferences" on a website, so they might have javascrpt enabled in their browsers but don't want the site to use it or to use use it, but at least they'd have a choice :-) Isn't that what we are here fore? Having choices and making our own decisions?*grin*

 

regards

 

Ralf

let me know if get into any problems with the code, I'll help as soon as I can

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

Ralf,

Although you don't think you're a JavaScript guru, you know mroe about it than I do!

 

One thing, and this may seem pedantic for those who run their sites in the root directory, though it may be a real issue for those who run theirs under 'domainname.com/catalog/'.

 

But is there any way to remove the second '/' that gets added by the redirect statement?

      tep_redirect(tep_href_link($PHP_SELF, tep_get_all_get_params($parameters)));

 

Also, as you will notice if you look at the URL of my WWW, I'm running the Ad Tracker contribution on my site. Is there some way for your code to remove the '?ref=sitename' from the URI?

This would be a fantastic option for the Ad Tracker contribution if possible, IMHO.

 

Thanks again for any help...

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

another change :-)

 

That should do it :-)

 

////////////////////////////////////////////////

// rb 20030803 13:00 JAVASCRIPT DETECTION

 if (!tep_session_is_registered('javascript')) {

   tep_session_register('javascript');

 }

 if (isset($HTTP_GET_VARS['javascript']) || isset($HTTP_POST_VARS['javascript'])) {



 $javascript = ((isset($HTTP_GET_VARS['javascript']) == 'on') || ( isset($HTTP_POST_VARS['javascript']) == 'on'))? 'on' : 'off';

 unset($HTTP_GET_VARS['javascript']);

 unset($HTTP_POST_VARS['javascript']);

 $parameters = array('javascript', 'pid', 'ref'); 

	 tep_redirect(tep_href_link(substr($PHP_SELF,1), tep_get_all_get_params($parameters)));

 }

// END JAVASCRIPT DETECTION

////////////////////////////////////////////////  

The reason is that $PHP_SELF always returns the DOCUMENT_URI, so the document and path relative to the WEBSERVER_ROOT_DIR, and not important here but to be complete the tep_get_all_get_params() returns also the get parameters given to the document except those namely listed in the array $parameters.

 

With the substr() we get rid of the always present preceeding slash from $PHP_SELF and with tep_get_all_get_params() we rebuilt the full REQUEST_PATH except for 'javascript' and 'ref' or whatever you don't want to show up. (sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

 

Enjoy :-)

 

regards

ralf

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

Ralf... YOU'RE DA MAN!

 

I don't know what code magic you're working there, but it's all going great!

Well... nearly... :)

The only part that isn't working is the redirect is still showing my '?ref=' could this be because it's using ? instead of &... does it matter which one I use?

Could it also be because I'm hard coding it into the URL on the linked site?

 

Ohh.. and if someone types any form of '&blah=blah' using the & symbol... the javascript code gets stuck in a continual loop.

 

Thanks again for all what you've done so far... it's MAGIC!

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

not really to say it would not matter what to use, the protocol for Http says that if a parameter list is passed to a document it has to start the list with a '?' Alle name value pairs in this parameter list have to be assigned with the the symbol '=' and the symbol '&' has to be used to separate all entries from each other. So that gives

 

http://server.domain.tld/uri.php?param=value

and

http://server.domain.tld/uri.php?param=val...e&param1=value1

 

etc.

 

If the parameter list is not started with a '?' then the webserver looks for a document named alike uri.php&param which he won't be able to find, so the server should return a "302 document not found" or a prepared error document (set by rules in httpd.conf or .htacces) or produced by a errorhandler (also set by rules in httpd.conf or .htacces).

 

I don't know and can not imagine what causes your loop. I will think about it. Maybe you'll find a hint on what s really going on if it loop. Do you have a shell access to your server? try tail -f /var/log/httpd/access.log or use the path where you know that your logs are stored to see wich document is being requested actually. (you can exit that command and the output and return to the shell wit CTRL+C.)

If that doesn't work insert a die() before the output for the javascript redirection as

<?php

} else {

?>

<script language="JavaScript">

<!--

window.location.href = document.URL + ((document.URL.match(/[?]/))? '&' : '?') + 'javascript=on';

//-->

</script> 

<?php

}

?>

to see if its really the javascript test that fails. If it dies then so please start debugging. Let php echo the values for javascript and even the ones for 'blah'. A full list you get (not always needed but helpfull with this)

/* // debugging help

         foreach (array_keys($HTTP_POST_VARS) as $tmp_str) {

           echo "keys: " . $tmp_str . ' : value ->' . $HTTP_POST_VARS[$tmp_str] . '<br />' . "n";

           if (is_array($HTTP_POST_VARS[$tmp_str])) {

             foreach ($HTTP_POST_VARS[$tmp_str] as $tmp_tmp_str) {

               echo '    : value ->' . $tmp_tmp_str . '<br />' . "n";

             }

           }

         }

*/        

Do the same accordingly for HTTP_GET_VARS and you can see what the server gets and how it modified what it got or if it didn't at all.

I am sorry to have no solution by now for this. I will look into it in the evening.

 

regards

 

Ralf

(GMT +01 ;-))

sometimes I change code before reading the comments, sometimes code doesn't even have comments, sometimes I rechange code after I read the code others wrote :-)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...