Drupal - Site transfer. Change absolute URLs in the database? - database

I have content in drupal (Blocks, Pages etc.) where absolute links have been inserted. I moved the site and the urls in the blocks and pages are still pointing to the old domain.
How can I change this in the database? Which database table do I need to target? I want to do something like:
UPDATE table SET content = REPLACE(content,'www.domain.com/old','www.domain.com/new');
Thanks!

Drupal it self is not using absolute paths (like i.e. WordPress does) so moving "common" Drupal websites doesn't require any intervention like this.
My advice is to always use root relative paths for internal links.
Basically you would have to replace ALL appearances of old domain with new one, so it would be best to export your database to sql file, do search/replace on that sql file and then import changed dump file to new domain database. Maybe clear all the caches before database export to reduce database size...

Backup your database first!
Install Adminer script and search whole database for previous (old) domain name. Or build SQL-query to search all tables if you like command line interface
See How to search and replace all instances of a string within a database? to know how to replace string in whole database.

Making this change to the database may not be the best practise, why don't you instead try using the base html tag within the head tag in the .html template file:
<head>
<base href="http://www.domain.com/new"
</head>
Refer to for more information on this tag: http://www.w3schools.com/tags/tag_base.asp

Related

How to show Image from local drive in Angular JS [duplicate]

I'm trying to retrieve a picture from my file system after a good storage,(instead of putting it in the database I copy it to the disc and i put the path to the db)
I had store the picture to c:\images\ folder and supposing that the name the complete path is c:\images\mypic.jpg
when I try to retrieve it a set the img src attribute to <img src="c:\images\mypic.jps"> by using some java code
in the browser console I found this error Not allowed to load local resource: file:///C://images//mypic.jpg
Question: how to fix these path problem ? where Should I store the pictures ? and from where should I retrieve them ?
sending tag <img src="c:\images\mypic.jpg"> would cause user browser to access image from his filesystem.
if you have to store images in folder located in c:\images i would suggest to create an servlet like images.jsp, that as a parameter takes name of a file, then sets servlet response content to an image/jpg and then loads bytes of image from server location and put it to a response.
But what you use to create your application? is it pure servlet? Spring? JSF?
Here you can find some info about, how to do it.
In Chrome, you are supposed to be able to allow this capability with a runtime flag --allow-file-access-from-files
However, it looks like there is a problem with current versions of Chrome (37, 38) where this doesn't work unless you also pass the runtime flag --disable-web-security
That's an unacceptable solution, except perhaps as a short-term workaround, but it has been identified as an issue:
https://code.google.com/p/chromium/issues/detail?id=379206
You have Two alternatives :
First one is to create a ServletImageLoader that would take as a parameter an identifier of your image (the path of the image or a hash) that you will use inside the Servlet to handle your image, and it will print to the response stream the loaded image from the server.
Second one is to create a folder inside your application's ROOT folder and just save the relative path to your images.
Many browsers have changed their security policies to no longer allow reading data directly from file shares or even local resources. You need to either place the files somewhere that your tomcat instance can serve them up and put a "regular" http url in the html you generate. This can be accomplished by either providing a servlet which reads and provides the file putting the file into a directory where tomcat will serve it up as "static" content.
The concept of http location and disk location is different. What you need to do is:
for uploaded file summer.jpg
move that under a known (to the application) location to disk, e.g c:\images\summer.jpg
insert into db record representing the image with text summer.jpg
to display it use plain <img src="images/summer.jpg" />
you need something (e.g apache) that will serve c:\images\ under your application's /images. If you cannot do this then in step #2 you need to save somewhere under your web root, e.g c:\my-applications\demo-app\build\images
This error means you can not directly load data from file system because there are security issues behind this. The only solution that I know is create a web service to serve load files.
Here is a simple expressjs solution if you just want to run this app locally and security is not a concern:
On your server.js or app.js file, add the following:
app.use('/local-files', express.static('/'));
That will serve your ENTIRE root directory under /local-files. Needless to say this is a really bad idea if you're planning to deploy this app anywhere other than your local machine.
Now, you can simply do:
<img src="/local-files/images/mypic.jps"/>
note: I'm running macOS. If you're using Windows you may have to search and remove 'C:\' from the path string
Do not use ABSOLUTE PATH to refer to the name of the image for example: C:/xamp/www/Archivos/images/templatemo_image_02_opt_20160401-1244.jpg. You must use the reference to its location within webserver. For example using ../../Archivos/images/templatemo_image_02_opt_20160401-1244.jpg depending on where your process is running.

Migrate views in drupal 7 easily - D7

I want to migrate all views from my local site to another site.
I know there is a module "Migrate" which allows you to do data migration but I don't know how to use it.
Can you give me some tips?
Thanks in advancej
Not sure what you mean with migrating views to another site. In Drupal, the migration concept is usually associated with actually migrating data - a view is actually just a way to query and display this data.
Typically moving a view to a different site, assuming data structures are the same in both can be accomplished by either exporting the view (one of the options while browsing the views on admin/structure/views) or, if it's not just a one of, by featurizing it which is a process that takes a few more steps.
It's only applicable for drupal site to drupal site
First download features module and enabled in both sites.
Go to admin-structure > features > create feature.
In that you can see General information(left side) and Components(right side). The General information provide some name in the name fields and you can see views in Components. You just select what are all views are needed for that site.Click the Download feature button.
It will downloaded!!!
After that copy the downloaded file to new drupal site which has drupalroot > sites > modules.
Go to your "new drupal site" as (Admin-Structure > feature). You can see the folder name as list in that. Enable the folder name list and click "Save settings". After the save setting finished as good then deselect the folder list, click "save settings" and delete the downloaded folder in module folder.
Note:
The folder name list should not state as conflict. If it presents, then click the recreate button.

dotnetnuke how to copy pages programatically

I have thousands of pages which i need to export from qa to production. I have seen the export page function but is there a way to do this in batch? I have found code to create pages but not to extract them. All permissions and settings must also be copied.
You could use the Portal Templates (export) feature found under the Host/Sites page.
That will generate a template for the site, then you could transfer that to production (that would be a couple of files) and "apply" that template to your existing site.
The other option would be to backup/restore the database, that is how most people handle changes between staging/production. Though that assumes any changes already made in Production exist in Staging.

cakephp upload image to folder and store reference on database

In the cakephp 2.0 application i'm developing i will need a HABTM relationship between a table with "normal" data and one with stored images.
After a search, i came to conclude that the best way of implementing this was to store the images in the directory of the application, and in the table "images" a reference to the url of each image so that i can display them later on the application. Please, if you think this is not the best implementation please say so.
Looking into this, i would like to know how can i do this, i mean, how can i store the images on directory and store a reference in a database in the same function of a controller?
I did some searchs but i found only uploading to folders or only storing the images on database.
Thank you!
My FileStorage plugin https://github.com/burzum/FileStorage in combination with the https://github.com/CakeDC/Imagine plugin will exactly do what you want.
All file data is stored in the database, the files itself in the local file system or any of the other adapters. It's also handling generating versions of the image after upload.
Read the readme.md it is exactly doing what you want and I'm already using it in different projects, also for a gallery and user avatars.

how to remove sitemap.aspx in dnn6

i need to remove sitemap.aspx from the site.
In dnn 6,there is a sitemap.aspx page that simply shows an xml sitemap.i cannot edit/remove that file.so i need to remove that page and recreate it with a simple html sitemap.
NOTE:the page name should be sitemap.aspx
Sitemap.aspx isn't a physical page you can delete.
You can, however, rename it to something else. It's in your web.config file, under the 'handlers' section. Just look for sitemap.aspx, and change it to something else, like 'searchenginesitemap.aspx'. Don't forget to update your robots.txt file to point to the new sitemap name, or go to the various webmaster console pages in search engines and advise them of the new location.
The sitemap.aspx is used to create the xml sitemap for search engines. By changing this you break this functionality and limit the search-ability of your site.
That being said, in Host Settings->Advance Settings you could setup a new Friendly Url that would match .*/sitemap.aspx to another url/page on your site.
I have long stopped using DNN's native sitemap.aspx... ITS BUGGY!... and here is how i found out.
I generated my own "CLEAN" sitemap.xml using a free 3rd party tool. And uploaded it to the root of my DNN website.... re-submitted the the domainname.com/sitemap.xml to Google via web master tools and as a result we now get a 1ST PAGE and TOP 10 RANKING.
Mostly in the top 5... where as before using DNN's native sitemap.aspx we would get random errors which was pretty ANNOYING. Plus we got very bad Google Page Rank, But those were just my findings of better results. Note:I also place the location of the sitemap within the robots.txt file...
Although i will admit that it is extremely ANNOYING that you cannot just edit the DNN Sitemap url. This creates an issue if you've built the the site on a test server and then migrate over to production... your DNN Sitemap url only reads the firs portal alias from when you first developed the site.
Anyway, this was my findings... others may vary... just sharing.

Resources