Jump to content
xisto Community
Sign in to follow this  
Amezis

Changing Include Tag On All Pages

Recommended Posts

I want to change an include tag (include menu.htm) to include menu.php on all my pages on my website. Is there any fast way to do this, or do I have to edit all of my pages manually? :)

Share this post


Link to post
Share on other sites

I want to change an include tag (include menu.htm) to include menu.php on all my pages on my website. Is there any fast way to do this, or do I have to edit all of my pages manually?

:)

175989[/snapback]

I don't think there is method to change it at once. You have to change htm to php in every page yhat u uses menu.

Share this post


Link to post
Share on other sites

Ok... I think I'll change everything that is included then... like the footer etc, maybe i'll need to have it in PHP later... Thanks for the info anyway...

Share this post


Link to post
Share on other sites

Well, if you are wanting menu.htm to function as a PHP script (without manually changing everything), you could add this to .htaccess:

AddType application/x-httpd-php .htm

That way you don't have to change everything that references it to menu.php (as that can get tiring if you have many files). Hope that helped you.

Share this post


Link to post
Share on other sites

Come on guys! Im really surprised! Does not any one know the "Find and Replace" function? (and dont tell me you dont use dreamweaver). Macromedia Dreamweaver has a very very powerful function, beyond what it looks. You can search and entire site for finding and replacing items, a whole folder. When you click control + find and open up your "Find and Replace" dialog box, you have a section called "find in:" where you can select from various destinations, including: "current document", "selected text", "open documents" (last one depending on the version i think), and: "folder... (browse)" (among others). Here you select the folder which you want to search. Then you have the "search" section which you set to "code" (it also has the value for searching "text" in the document(s), only text but no html nor other kind of code, and "specific tag", which can for example, remove desired atributes from any given tag).Then you have the "find" text box, where you type what you want to replace, example "<?php include ("menu.htm"); ?>" and the "replace" text box, which you could set to: ""<?php include ("menu.php"); ?>".Yes, some times dreamweaver does more that what you want with your code, it leaves garbage in it, but in cases like this, it could save you a looooooooooot of work :)

Share this post


Link to post
Share on other sites

I was going to say, if you have Dreamweaver, use find and replace. But if you don't...well, notepad has one, but you can't edit multiple files at once, so I don't know how else to help you...Sorry!

Share this post


Link to post
Share on other sites

I was going to say, if you have Dreamweaver, use find and replace. But if you don't...well, notepad has one, but you can't edit multiple files at once, so I don't know how else to help you...Sorry!

There are plenty of text-based HTML editors that do allow multiple file search and replace though. Get yourself one and it'll be done in a second.

Share this post


Link to post
Share on other sites

There are plenty of text-based HTML editors that do allow multiple file search and replace though. Get yourself one and it'll be done in a second.

183396[/snapback]

Ive used Crimson Editor, the only editor i know. And as i dont have it installed right now on this machine i couldnt say if it can search multiple files, but i believe it can. And its freeware! But its only for windows i think. Could you point out more of those editors?

Share this post


Link to post
Share on other sites

If you're on a mac box, bbedit is the answer to every text based problem (well the ones that you couldn't be bothered learning PERL for, anyway). Unfortunately, you problably aren't on a mac.My personal favourite is SciTE on win/linux. CrimsonEdit is good too, but really it's just a KATE imitation. I'm not sure if either of these do multiple-file search and replace, though, and I can't check (short of installing X11 on this mac and then SciTE, but i'm feeling lazy right now).Of course, if you felt like using PHP for this job, you could do something likea) read all filenames into an array, using opendir, readdir, et. al.:) open each file sequentially, reading contents into string - say $StringWithTheFileInIt = file_get_contents ($filename) or something.c) do $new_string = preg_replace ("/include\s+?(\s+?'menu.htm'\s+?);/i", "/include ('menu.php');/", $StringWithTheFileInIt);. That scary-lookin thing just looks through $StringWithTheFileInIt, and replaces the old text with the new. The \s+? are to allow for any whitespace you may or may not have put in.d) overwrite the old file with the contents of $new_string, using fopen ( $filename, 'w' ).e) rinse, lather, repeat until done.Since you're using menu.php, i'm assuming that you know what most of that means :| If you do do this - i recommend you back up your stuff first in case you make a mistake and things go horribly wrong. I know the true pain of accidentally overwriting 10mb of text files with the string 'hello world'...... not cool.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.