MarcC Posted October 26, 2012 Share Posted October 26, 2012 Let's say I develop a site in a subdirectory, like /newsite. Now I'm ready to launch the site and all of my TinyMCE link hrefs start with "/newsite". Is there a way to mitigate the need to go in and replace all of those with the correct address? Link to comment Share on other sites More sharing options...
Soma Posted October 26, 2012 Share Posted October 26, 2012 There's a module you could use... but before you start, afterwards it won't work unless you maybe resave all pages via API when still n subdir. http://modules.processwire.com/search/?q=abstract Link to comment Share on other sites More sharing options...
teppo Posted October 28, 2012 Share Posted October 28, 2012 Page Link Abstractor is a splendid module, but it also introduces a rather big change to the way PW handles links. If you "just" want a one-time fix for changed links, it might be easier to run a simple SQL query for fields that contain changed links, replacing old links with new ones. Something like "UPDATE field_yourfield SET data = REPLACE(data, 'href="/newsite', 'href="');" should do the trick. Since I'm not sure how familiar you are with MySQL / SQL in general, this may be self-evident to you, but still: a) if you're not absolutely sure about what you're doing, don't try method I mentioned above and b) always make a backup of the table you're working with before making any changes to existing data (CREATE TABLE backup_field_yourfield LIKE field_yourfield; INSERT INTO backup_field_yourfield SELECT * FROM field_yourfield;) By the way, Page Link Abstractors description says that "This module hasn't yet been tested with migrating a site from subdirectory to root, but I will be testing this soon." Old information perhaps? 2 Link to comment Share on other sites More sharing options...
Soma Posted October 28, 2012 Share Posted October 28, 2012 Without SQL you could do it with simple bootstrap or in a template: foreach($pages->find("template=basic-page") as $p){ $p->body = str_replace("/newsite/","/",$p->body); $p->save(); } 3 Link to comment Share on other sites More sharing options...
ryan Posted October 28, 2012 Share Posted October 28, 2012 I have this same issue when doing one-time migrations of finished sites on my localhost MAMP/dev server (which runs sites off subdirs) to the live server. But the solution is really simple. When I export the database to an SQL dump (via PhpMyAdmin), I drag the resulting SQL file into TextWrangler/BBedit, and perform a search/replace: "/newsite/" => "/". Then I import it to new server (again via PhpMyAdmin). Problem solved on 5 seconds. 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted October 8, 2014 Share Posted October 8, 2014 Performing replacement in database dump is a working solution. But still, Is there a way to configure RTE to insert relative links instead so the replacement won't be even necessary? And make them relative to site root? I used to do it this way in Joomla, but it does not work in PW. If I manually correct the link to not start with "/" it becomes relative, but relative to the current URL, not the root. Can the desired be accomplished? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now