July 22, 20188 yr My website https://www.kirkbymicrowave.co.uk/ should have a menu at the top of each page. It is included by a bit of php like this, which includes menu.php. <?php include ("../../menu.php"); ?> The deeper the page is below the root, the further up the directory structure menu.php is, so in principle a page might have <?php include ("../../../../../../../../menu.php"); ?> although I don't have any pages that deep! If I move a page up or down a directory level, I need to remember to change the path to menu.php (for some annoying reason /menu.php does not work). The problem is, sometimes I forget to update the reference properly, so end up with a page like this. https://www.kirkbymicrowave.co.uk/Support/FAQ/page-screwed-up/ Is there any obvious way of finding problems like this? I have shell access on the Apache server. : There should be a footer too. Again included with a bit of php code, and again needs to have the correct path. I'd like to try to find some automated way of checking every page, to see if it has both the menu and the footer you see on most pages. Dave Edited July 22, 20188 yr by drkirkby clarify things, with more details.
July 22, 20188 yr Use a CMS. It will solve so many of your problems. However... Keep it really simple: <?php include ("https://www.kirkbymicrowave.co.uk/menu.php"); ?> No need to worry about levels. And simplify your directory structure: https://www.kirkbymicrowave.co.uk/Support/page-screwed-up/ not: https://www.kirkbymicrowave.co.uk/Support/FAQ/page-screwed-up/ Fewer folders mean less chances of broken links. As for automated checking, it depends on what editor you are using. I use brakets (for a mac) and it does all this for you. Edited July 22, 20188 yr by fisicx
July 22, 20188 yr Author I thought a reference to include ("https://www.kirkbymicrowave.co.uk/menu.php"); would slow things down, as a DNS lookup needs to be performed, whereas a link to a file is faster. I am thinking of migrating to WordPress, but have not made my mind up yet. I'm trying to weigh up the advantages vs disadvantages, given most of the content is written. I think if starting a few site from scratch, I would probably not hand-code all the HTML again. Dave
July 22, 20188 yr 3 minutes ago, fisicx said: Keep it really simple: <?php include ("https://www.kirkbymicrowave.co.uk/menu.php"); ?> No need to worry about levels. I agree on principal, but not all php files should be accessible direct, some should even be kept outside the root for security. I normally set a core path and then use absolute paths to other files, this saves relative heartache during development or moving files. This can be done in a few ways, normally this would work fine (on most hosts I've tried) and where you store the include file would be outside the root. So structure assuming 'Site' is the host root. Then in the core.php file; <?php $main_path = "/var/sites/y/yoursite.co.uk"; $public_path = $main_path . "/public_html"; ?> In a public page you can add this right at the start; <?php include("/var/sites/y/yoursite.co.uk/inc/core.php"); ?> So now in any file you can access either a secure file or public file with ease, like the menu; <?php include($public_path."/menu.php"); ?> Now everything would be root down, so absolute rather than relative. Also means you can store all you database connects etc outside the public root.
July 22, 20188 yr Even better than my suggestion. Certainly avoid using ../../ wherever possible @drkirkby what is your objection to using a CMS? It will make your life so much simpler and you will be able to include things like a site search - a useful feature for a service like yours. Moving your content to WordPress or any other CMS is a doddle. Wordpress offers all sorts of tools to help you with this. Copy all your content to excel, save as a CSV and use something like this: https://wordpress.org/plugins/wp-ultimate-csv-importer/ Edited July 22, 20188 yr by fisicx
July 22, 20188 yr PS: you will get lots of people telling you not to use plugins. But in this case you will only use it once then uninstall so it's not going to be an issue.
July 22, 20188 yr Author @fisick I don't really object to a CMS. It is just weighing up the time spent to learn it, or the cost to pay someone else to do the work. I'd rather spend the time myself, to save money, but also the skills I can use on another site. I have in fact bought a book on WordPress, but have not opened it. I also bought a couple of books on SEO, which I have started reading. Dave
July 22, 20188 yr You don't really need a book on WordPress. Here's a simple example of how a menu works. Login to your dashboard (admin area). Go to Appearance > Menus Create a menu by giving it a name (eg: main). Select which pages you want in the menu from the list of pages. Drag and drop to reorder. Drag to the right to create a sub-menu item (for a drop down) Save the menu. That's is. nothing else to do. Wordpress will display this menu on every page. The style of the menu is determined by the theme. If you switch themes the menu still exists, you just need to tell the theme which menu to put where.
July 22, 20188 yr Author I'm sure it would take me many days of work to get the website "right". Dave
July 22, 20188 yr Trust me on this. If you have the content you will be able to publish a working wordpress site in a few hours. The key to the website is the content and how it is organised. The layout for a service like yours is almost irrelevant. All you need to do is pick one of the thousands of free themes and let wordpress do all the complicated bit for you. You don't even need to worry about links - you can fix all these in seconds. Don't worry about the site being 'right'. Just make sure the content is properly organised and accessible.
Create an account or sign in to comment