Associate
- Joined
- 5 Jun 2004
- Posts
- 1,341
- Location
- Hythe, Hants
Ok here it is guys, what I'm trying to do here is create an unordered list with all the menu items in their relevent positions, the function works fine if I replace $output to echo, but seeing as I don't want this function run every time someone visits the website I just want it run on the admin side of things, so i thought lets try and dump the data into a file we can just "include" it on the website.
Like I said It runs fine if I replace $output with echo, but if I just return $output it only appears to go over the loop once.
Brain has hit a dead spot and i've been fiddling with it for hours now with varying results, none of which work :s
Any Ideas guys?
I then run the function like so:
Like I said It runs fine if I replace $output with echo, but if I just return $output it only appears to go over the loop once.
Brain has hit a dead spot and i've been fiddling with it for hours now with varying results, none of which work :s
Any Ideas guys?
Code:
function rebuild_links($x = 0, $tmp) {
$mysql = new MySql();
$result = $mysql->query("SELECT * FROM menu_tree WHERE template='".$tmp."' AND parent_id= '".$x."' ORDER BY homepage DESC, sortorder ASC");
if($result->num_rows() > 0) {
$output .= "\n <ul>\n";
while($result->next()) {
$output .= ' <li><a href="index.php?fn='.$result->row['filename'].'&pid='.$result->row['id'].'">'.$result->row['menu_name'].'</a>';
rebuild_links($result->row['id'], $tmp);
$output .= "</li>\n";
}
$output .= " </ul>";
}
return $output;
$mysql->close($result);
}
I then run the function like so:
Code:
$output = rebuild_links(0, ''.TEMPLATE_NAME.'');
$fp = @fopen('../templates/'.TEMPLATE_NAME.'/navigation.php', 'w');
if (!$fp) {
echo 'Well bugger me sensless and call me mary! something wrong happend.';
}
fwrite($fp, $output);
fclose($fp);
Last edited: