UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsite.com', 'http://www.newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldsite.com','http://www.newsite.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldsite.com', 'http://www.newsite.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldsite.com','http://www.newsite.com');
Tuesday, July 25, 2017
Update Wordpress Domain When Migrating
When you're migrating a Wordpress site to a new environment, having to change the domain name can be a bit of a pain. There are some plugins you can use, but if you're relatively comfortable with SQL queries you can do it manually.
Monday, June 26, 2017
Get rid of Sitecore trying to set language from URL
Could not parse the language 'XXXX'. Note that a custom language name must be on the form: isoLanguageCode-isoRegionCode-customName. The language codes are two-letter ISO 639-1, and the regions codes are are two-letter ISO 3166. Also, customName must not exceed 8 characters in length. Valid example: en-US-East. For the full list of requirements, see...
If you're getting the following error when loading URLs, and you don't need a language requirement, you can turn off the Sitecore setting in the web.config.
If you're getting the following error when loading URLs, and you don't need a language requirement, you can turn off the Sitecore setting in the web.config.
- Under the "linkManager" sitecore item, set "languageEmbedding" to "never"
- Under the "Languages.AlwaysStripLanguage" setting, set value to "false"
Wednesday, June 21, 2017
Updating npm and node on Windows
To update npm and node on Windows, follow these steps from a StackOverflow answer:
Run PowerShell as Administrator
How do I update node and npm on windows?
Run PowerShell as Administrator
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
npm install -g npm-windows-upgrade
npm-windows-upgrade
How do I update node and npm on windows?
Thursday, June 15, 2017
Creating a Website in Microsoft Azure with GitHub deployment
Microsoft Azure is a scalable, cloud-based web hosting solution.
At the moment, it's not possible to use an external Git repository for Azure and have staging and master branches that automatically deploy to Azure. GitHub is the suggested method of source control for now. First, create the GitHub repository and the master and staging branches. Once created, go back into Azure to connect the Web App to the repository.
Setting up a new Web App
- Create a Subscription
- This is the billing account to use. You can use an existing one or create a new one.
- To create a new Subscription account, in the Azure portal left sidebar, click on Subscriptions > Add
- Select the payment account to use
- Create a new Web App and App Service Plan
- The App Service Plan is the container for Web Apps. You can have multiple Web Apps in a single App Service Plan. Plans vary in bandwidth and are priced in tiers.
- In the left sidebar again, click on App Services > Add
- Select Web App > Create
- Fill in App name -- this will be used for your Azure URL on *.azurewebsites.net
- Select Subscription that you created previously
- Resource Group can be new, or you can use an existing one if there is one for that App Service
- App Service Plan: Create new is default, but only use if there isn't one already; otherwise use one that's already there.
- Click Create and Azure will begin deploying the new site. After 1-2 minutes, you should see an Alert that deployment is complete
- Now if you go to App Services the new web app will be there. If you select it and click Overview you will see URL, FTP and other info.
- Select/Change Service Plan ***Azure will select Standard by default, so you need to manually change it if you want a free/cheaper plan
- Go to App Services > Scale Up and view the current plan or select a different plan
Setting up a Staging Environment
You can create a separate Web App for staging in the same App Service Plan, or you can create a Deployment Slot in the existing production Web App. Personally I think it is cleaner to use Deployment Slots, to minimize the number of Web Apps. Originally Deployment Slots were meant to be a pre-production environment that you can swap out with the real production environment. For example, you could deploy code changes to the Deployment Slot, then once it's working "Swap" the Deployment Slot and it will immediately update the Production environment. However I think this a different type of workflow than what I usually do with Git and having staging and master branches that deploy to the environments. I don't plan on using the Swap functionality, but many others like using it.- To create a deployment slot, select the App Service and click on Deployment slots > Add Slot
- Name it, i.e. "staging" -- this will create a new subdomain on the *.azurewebsites.net site by adding the slot name to the existing Azure domain
- Under Configuration Source, select to clone from the existing Web App
- Click OK to create the new deployment slot
Setting up GitHub Deployment
At the moment, it's not possible to use an external Git repository for Azure and have staging and master branches that automatically deploy to Azure. GitHub is the suggested method of source control for now. First, create the GitHub repository and the master and staging branches. Once created, go back into Azure to connect the Web App to the repository.- Select the App Service (or App Service's Deployment Slot) > Deployment option
- Under Choose Source, select GitHub. You may be prompted to log into GitHub; if so, log in using devservices (Credentials in 1Pass under GitHub)
- Select Authorization, Organization, Project, and Branch.
- Click OK to create the Deployment option.
- Depending on how many files are in the repo, it make take a few minutes or longer to finish building the site. You can check the deployment status under Web App > Deployment options
Friday, May 12, 2017
Sitecore Admin Menus
Sitecore Admin Pages Explained, from the blog Fire Breaks Ice
Sitecore comes shipped with a plethora of admin pages that provide significant features to developers and administrators. Many of these pages aren’t exactly documented well or at all. I intend to identify and explain the admin pages that I know of and how they can be used to your advantage.
Read More:
http://firebreaksice.com/sitecore-admin-pages-explained/
Sitecore comes shipped with a plethora of admin pages that provide significant features to developers and administrators. Many of these pages aren’t exactly documented well or at all. I intend to identify and explain the admin pages that I know of and how they can be used to your advantage.
Read More:
http://firebreaksice.com/sitecore-admin-pages-explained/
Wednesday, May 10, 2017
Undoing a merge in Sourcetree/Git
Merging some changes into your master branch, then realizing you need an undo function, is stressful. Fortunately, whether or not you've pushed your merge, you can still reverse what you did. There's no actual "undo" in Git, but you can either reset the master branch, or reverse your changes.
If you haven't pushed to the origin master branch yet, you can reset the master branch to the previous commit before the merge. You'll want to reset using "Hard" mode so that your working copy of master will have the changes removed.
Sourcetree:
Right-click the previous commit on the master branch, select "Reset current branch to this commit" and select "Hard" mode.
Git Command Line:
git reset --hard XXXXXXX (insert the Commit ID)
If your merge to master has been pushed, then you will need to do a reverse commit in the feature branch, which reverts everything in that commit, merge to master, then push master again. Later on, if you want to re-merge what was in the feature branch to master once again, you will have to reverse commit the reversion itself in the feature branch. This will reinstate the changes you had removed.
If you haven't pushed to the origin master branch yet, you can reset the master branch to the previous commit before the merge. You'll want to reset using "Hard" mode so that your working copy of master will have the changes removed.
Sourcetree:
Right-click the previous commit on the master branch, select "Reset current branch to this commit" and select "Hard" mode.
Git Command Line:
git reset --hard XXXXXXX (insert the Commit ID)
If your merge to master has been pushed, then you will need to do a reverse commit in the feature branch, which reverts everything in that commit, merge to master, then push master again. Later on, if you want to re-merge what was in the feature branch to master once again, you will have to reverse commit the reversion itself in the feature branch. This will reinstate the changes you had removed.
Monday, May 1, 2017
Using setInterval to run a script after element is finished loading from server
Sometimes I need to run a JS script on a set of HTML elements, but I run into problems when the script fires before elements or assets are finished loading from the server side.
For example, let's say I'm loading a grid of items, each of which has an image and some copy underneath. I want each item in the grid to be the same height, regardless of how much text it has. Generally I'd run a JS script to set the heights of all the items to the height of the tallest item.
However, since I'm loading the images through a CMS off the server, it sometimes takes a little bit before they are all loaded. If I run the script normally, it will fire before all the images finish loading, and it will resize the items to a height that is too short.
I've found that using the javascript function "setInterval" is a good solution; it runs at a frequency of your choosing, and each time it checks if the slower-loading element is loaded. If it isn't loaded, it will simply repeat the function; if the element is found to be finished loading, then it will run another JS script of your choosing, and clear the interval to stop checking.
For example, let's say I'm loading a grid of items, each of which has an image and some copy underneath. I want each item in the grid to be the same height, regardless of how much text it has. Generally I'd run a JS script to set the heights of all the items to the height of the tallest item.
However, since I'm loading the images through a CMS off the server, it sometimes takes a little bit before they are all loaded. If I run the script normally, it will fire before all the images finish loading, and it will resize the items to a height that is too short.
I've found that using the javascript function "setInterval" is a good solution; it runs at a frequency of your choosing, and each time it checks if the slower-loading element is loaded. If it isn't loaded, it will simply repeat the function; if the element is found to be finished loading, then it will run another JS script of your choosing, and clear the interval to stop checking.
// create your interval function as a named variable; having a name allows you to clear it later
var checkImages = setInterval(function () {
// This checks the height of the last grid item's image, since it will be loaded last.
// Once it's loaded, the height will be more than 0.
if ($('.grid:last img').height() > 0) {
// if the image is done loading, clear out the interval
clearInterval(checkImages);
// then run the script you want; this just happens to be the one I'm using
equalizeHeights($('.grid__item'));
}
else {
}
}, 200); // run this every 200 ms
Subscribe to:
Posts (Atom)