简体   繁体   中英

Build a Sitemap but webpages don't use links

Folks I am trying to build a sitemap (we need one badly) for a huge multi-page web app. Technically its not much more than a collection of php/MySQL web forms that use javascript instead of traditional linkage to access the many pages.

<td width="100" align="center" ONMOUSEOVER="this.className='bgover'" ONMOUSEOUT="this.className='bgout'" onclick="location.href='../main.php'">Main Page</td>

Above is code sample of how the links are currently managed. I know I can search through the various pages, nearly a 1000, and find these "location.href" variables and that will help me a sitemap for each section. But maybe there is an easier way? WE use Trac and SVN so perhaps I am going about this the wrong way? Any advice would be appreciated.

You could use the recursive directory iterator to get a list of all the pages in your site.

This is dependent on whether or not you want every page to be visible to the outside world. If you have some config or private/admin files I would suggest moving them outside of the web root, or only putting your public stuff inside a particular folder.

Edit: Your question is very confusing, I will delete this answer if I misunderstood your question.

My recommendation is to fix the code. You could create a php script that could replace that code with

<td width="100" align="center" ONMOUSEOVER="this.className='bgover'" ONMOUSEOUT="this.className='bgout'"><a href="../main.php">Main Page</a></td>

If this is not an option you could write a script that goes through your entire site folder structure and creates a sitemap from all the files. Depending on your folder structure it could be quite easy.

So how does someone with javascript disabled on their browser navigate your site? Not having regular anchor tags for linking pages is a very bad way of doing things. I would probably use something like

grep -ri /location\.href='[^']/ . > links

to build a file called links that shows each line of code containing a javascript link and use it as the first step to building the sitemap. Without much more information on the structure of your system, its difficult to give more direction than that.

I'll point you to my answer elsewhere :

Linking a visual sitemap with a web application

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM