Page 1 of 2
Dropdown Menu Parse Error
Posted: Tue 15. Feb 2005, 10:39
by TheMouse
Hi,
In attempting to implement the CSS Dropdown menu I'm getting a parse error on line five of:
Code: Select all
<?php
// -------------------------------------------------------------
if( ! ( strpos($content["all"],'{DROPDOWN')===false ) ) {
$content["all"] = str_replace('{DROPDOWN}', '{DROPDOWN:0}', $content["all"]);
$replace = 'build_dhtmlmenu('$1','id="nav"',0);';
$content["all"] = preg_replace('/\{DROPDOWN:(\d+)\}/e', $replace, $content["all"]);
}
// -------------------------------------------------------------
?>
Locatied in my /public_html/phpwcms_template/inc_script/frontend_init folder.
Can anyone spot the error?
Thanks
Mouse[/url]
Posted: Tue 15. Feb 2005, 11:30
by brans
1.) this must be placed inside the frontend_render folder:
2.)
Code: Select all
<?php
// -------------------------------------------------------------
if( ! ( strpos($content["all"],'{DROPDOWN')===false ) ) {
$content["all"] = str_replace('{DROPDOWN}', '{DROPDOWN:0}', $content["all"]);
$replace = 'build_dhtmlmenu( "$1","id=nav", 0);';
$content["all"] = preg_replace('/\{DROPDOWN:(\d+)\}/e', $replace, $content["all"]);
}
// -------------------------------------------------------------
?>
should do it.
Posted: Tue 15. Feb 2005, 11:55
by frold
and you have to enable frontend render in conf.inc.php
Dummies guide required!
Posted: Tue 15. Feb 2005, 12:49
by TheMouse
Thanks for you help but... I just can't get this to work.
I'm no longer getting an error but I'm not getting a dropdown menu either - just a simple <ul> type list where I put the {DROPDOWN} tag.
What am I missing? Can you provide a step-by-step guide?
Thanks
Mouse
Posted: Tue 15. Feb 2005, 13:33
by brans
but the list is created correctly from the level that you have specified as startid, right ? then just try the following code:
Code: Select all
<?php
// -------------------------------------------------------------
if( ! ( strpos($content["all"],'{DROPDOWN')===false ) ) {
$content["all"] = str_replace('{DROPDOWN}', '{DROPDOWN:0}', $content["all"]);
$replace = 'build_dhtmlmenu( $1, id=nav, 0);';
$content["all"] = preg_replace('/\{DROPDOWN:(\d+)\}/e', $replace, $content["all"]);
}
// -------------------------------------------------------------
?>
in my opinion it would be strange if this was working but just go for it

Re: Dummies guide required!
Posted: Tue 15. Feb 2005, 13:36
by frold
TheMouse wrote:Thanks for you help but... I just can't get this to work.
I'm no longer getting an error but I'm not getting a dropdown menu either - just a simple <ul> type list where I put the {DROPDOWN} tag.
What am I missing? Can you provide a step-by-step guide?
Thanks
Mouse
'
what version do you use...?
Posted: Tue 15. Feb 2005, 13:50
by brans
another solution by pappnase:
$content["all"] = preg_replace('/\{D:(.*?)\}/ie', 'myRT1("$1")', $content["all"]);
so just use:
$content["all"] = preg_replace('/\{DROPDOWN:(.*?)\}/ie', 'build_dhtmlmenu("$1")', $content["all"]);
but then you will always have to specify the following:
{DROPDOWN:0,id="nav",0}
change the parameters as needed.
Ohhh yes! Is that right: You have created a dhtmlmenu but you haven't actually added any css but the list is created correctly with the id parameter added ?
<ul id="nav"><li>.....</ul> ?!?
In ordner to get the css menu running, you will have to implement some JS or css or whatever... just search try to search for:
author: brans
keyword: css
author: paschulke
keyword: css
Working - Thanks
Posted: Tue 15. Feb 2005, 14:28
by TheMouse
Thanks to you all.
After all that I'm not sure what was causing the problem! I started again using your advice and this time it works.
The problem was definitely related to the creation of the dhtml list though - it was not being created with the 'nav' id.
Thanks again
Mouse.
btw I think there is definitely a need for a 'beginners guide to dropdown menus'
Posted: Tue 15. Feb 2005, 14:33
by brans
ok please tell me what code was finally working for you so that I can create some tutorial at our dev site... And what version of phpwcms are you using ?
Posted: Tue 15. Feb 2005, 15:24
by TheMouse
THe code I'm using now is:
In the render directory:
Code: Select all
<?php
if( ! ( strpos($content["all"],'{DROPDOWN')===false ) ) {
$content["all"] = str_replace('{DROPDOWN}', '{DROPDOWN:0}', $content["all"]);
$replace = 'build_dhtmlmenu( "$1","id=nav", 0);';
$content["all"] = preg_replace('/\{DROPDOWN:(\d+)\}/e', $replace, $content["all"]);
}
?>
in the dropdown.js in the inc_js directory:
Code: Select all
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
and in the frontend.css file:
Code: Select all
/* BEGIN Menu Definitions */
#nav, #nav ul {
position: absolute;
top: 130px;
*/float: left;*/
width: auto;
list-style: none;
line-height: 1;
background-color: #496A91;
background-image: url(/img/nav_btm.gif);
background-repeat: repeat-x;
background-position: left bottom;
/* border-bottom: 1px solid #000000; */
font-weight: bold;
font-size: x-small;
* font-size: smaller;
padding: 0;
margin: 0 0 -1px 0;
* margin: -2px 0 0 0;
}
#nav a {
display: block;
width: auto;
w\idth: auto;
filter:progid:DXImageTransform.Microsoft.dropshadow(OffX=1, OffY=1, Color='black', Positive='true');
color: #FFFFFF;
text-decoration: none;
text-shadow: #000000 2px 2px 2px;
padding: 0.5em 1em;
}
#nav li.active {
background-color: #000000;
background-image:url(/img/nav_btm_hover.gif);
background-repeat: repeat-x;
background-position: left bottom;
color: #FFFFFF;
}
#nav li {
float: left;
padding: 0;
width: auto;
/* border-right: 1px solid #777777; */
}
#nav li ul {
position: absolute;
left: -999em;
height: auto;
width: 150px;
w\idth: 150px;
font-weight: bold;
* font-size: xx-small;
border: solid #777777;
border-width: 1px 0 0 1px;
margin: 0 0 0 0;
}
#nav li li {
/* padding-right: 1em; */
width: 150px;
/* border-bottom: 1px solid #222222; */
}
#nav li ul a {
width: auto;
w\idth: auto;
}
#nav li ul ul {
margin: -2.1em 0 0 150px;
}
#nav li:hover ul ul, #nav li:hover ul ul ul, #nav li.sfhover ul ul, #nav li.sfhover ul ul ul {
left: -999em;
}
#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul {
left: auto;
}
#nav li:hover, #nav li.sfhover {
background-color: #000000;
background-image:url(/img/nav_btm_hover.gif);
background-repeat: repeat-x;
background-position: left bottom;
color: #FFFFFF;
}
/* END Menu Definitions */
Most of this is from this thread:
http://www.phpwcms.de/forum/viewtopic.php?t=5361
It still isn't behaving quite right though - see
http://www.aurabeauty.co.uk/index.php
Cheers
Mouse
Posted: Sat 19. Feb 2005, 19:14
by cyrano
hi,
i tried to setup the dropdown menu and get this error:
Code: Select all
Fatal error: Call to undefined function: build_dhtmlmenu() in /www/htdocs/xxx/phpwcms_template/inc_script/frontend_render/reptag_dropdown.php(6) : regexp code on line 1
On Line 1 is only the opening php tag...
What does it mean?
I have put the files in the folders, set frontend_init and frontend_render to 1 in config.php?
Thanks for tips.
Can the vertikal and horizontal menu function used both at the same time?
Posted: Sun 20. Feb 2005, 10:58
by TheMouse
Sounds like you need this code:
Code: Select all
function build_dhtmlmenu($start=0, $class, $counter=0) {
$s = '';
$g = '';
foreach($GLOBALS['content']['struct'] as $key => $value) {
if ($start == $GLOBALS['content']['struct'][$key]['acat_struct'] &&
!$GLOBALS['content']['struct'][$key]['acat_hidden'] && $key)
{
$s .= '<li>';
if(!$GLOBALS['content']['struct'][$key]["acat_redirect"]) {
$s .= '<a href="index.php?';
if($GLOBALS['content']['struct'][$key]['acat_alias']) {
$s .= $GLOBALS['content']['struct'][$key]['acat_alias'];
} else {
$s .= 'id='.$key.',0,0,1,0,0';
}
$s .= '">';
} else {
$redirect = get_redirect_link($GLOBALS['content']['struct'][$key]["acat_redirect"], ' ', '');
$s .= '<a href="'.$redirect['link'].'"'.$redirect['target'].'>';
}
$s .= html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']);
$s .= '</a>';
$s .= build_dhtmlmenu($key, $class, $counter+1);
$s .= "</li>\n";
}
}
if($s) {
$g = "\n<ul";
if(!$counter && $class) $g .= ' '.$class;
$g .= ">\n".$s.'</ul>';
}
return $g;
}
in a .php file in your /phpwcms_template/inc_script/frontend_render/ directory.
I think this function is included in the latest build of phpwcms but it wasn't in mine.
HTH
Mouse
Posted: Sun 20. Feb 2005, 11:02
by brans
yes this code is only included from DEV 1.1.5 on, I will add this notice to the dev site.
Updated: --...--/index.php?topic=68.msg123#msg123
Posted: Sun 20. Feb 2005, 11:19
by cyrano
Hi Mouse, hi brans,
thanx for your hints.
I added the code Mouse has shown into a php-file and put in the frontend_render folder in a 1.1 RC 27-08-04 version, but still lacks...
I got the same error.
Is it right that it works only in the dev releases since 1.2?
There it works, but not with older ones...
Posted: Sun 20. Feb 2005, 11:39
by pico
Frontend Rendering is a new Function - it is not avaible in 1.1 RC4