Amezis 0 Report post Posted August 18, 2005 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
kasm 0 Report post Posted August 18, 2005 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
HmmZ 0 Report post Posted August 18, 2005 impossibleYou will have to do it manually Share this post Link to post Share on other sites
Amezis 0 Report post Posted August 18, 2005 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
Hamtaro 0 Report post Posted August 18, 2005 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
Amezis 0 Report post Posted August 19, 2005 Umm I think i'll change everything anyway... But thank you anyway. Share this post Link to post Share on other sites
Lozbo 0 Report post Posted September 7, 2005 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
arboc7 0 Report post Posted September 8, 2005 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
Tyssen 0 Report post Posted September 8, 2005 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
Lozbo 0 Report post Posted September 8, 2005 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
Tyssen 0 Report post Posted September 8, 2005 There's a thread about some of the best ones here. Share this post Link to post Share on other sites
littleweseth 0 Report post Posted September 9, 2005 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