Script in tools but with menu etc

Permalink
I've got a PHP script currently sitting in the /tools folder since I need an onload and onunload but I would like to:
a) include the normal C5 menu bar
b) know the logged-in user ID

Is there a way of either including the normal C5 stuff, or putting my script somewhere else where my JavaScript is going to work?

hockeyshooter
 
hockeyshooter replied on at Permalink Reply
hockeyshooter
Incidentally, in order to avoid using onload and onunload in the <body> statement, I did try using:
$(document).ready()

...in JavaScript, but the C5 menu bar disappeared. So I'm back to having to have my script in /tools
hockeyshooter replied on at Permalink Reply
hockeyshooter
As a "single page" I can get the Google map to appear and my data is added to it, but for some reason I don't see the normal site menu bar (although I do get the admin bar at the top). Do I have to add something specific to the top of my script to make the menu bar display?
ryan replied on at Permalink Reply
ryan
the layout of single pages are determined by the view.php in your theme.

Most themes just wrap the page in a super simple way (kinda the point), but if you want top navigation & such, just open up one of your theme pages (default.php possibly) then replace the main content area
<?php
$a = new Area('Main');
$a->display($c);
?>
[code]
with the contents of your single page:
[code]
<?php echo $innerContent ?>


You can then put the page in edit mode and add the same autonav block or whatever that you have on your other pages.
hockeyshooter replied on at Permalink Reply
hockeyshooter
OK, have copied suggested stuff into my script, so I now have:
<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$db = Loader::db();
?>
<div id="central" class="no-sidebar">
<div id="body">   
...all my JavaScript and code here...
</div>
</div>
<?php $this->inc('elements/footer.php'); ?>


I can then use the in-built page editor to add the top-level menu, but it appears as a vertical bulleted list.

If I also add this at the top:
$this->inc('elements/header.php');

I get the header twice.
ryan replied on at Permalink Reply
ryan
Edit the header nav, select custom template -> header nav or something like that. That should get rid of the list.
hockeyshooter replied on at Permalink Reply
hockeyshooter
That's done it! Thanks.

Now I've got to persuade my script with two embedded maps to work!
hockeyshooter replied on at Permalink Reply
hockeyshooter
As a hint to anyone wanting to use embedded Google Maps, it appears their scripts are very fussy about the order in which pages are created. As a guide, put the JavaScript block that actually puts the map on screen as late in your script as possible - define all the functions it calls first, then use the "map = new GMap2" last, even if this means having it a completely separate JavaScript block.