ZodiacPress Atlas separate Datenbank

ZodiacPress Atlas separate Datenbank

Install Atlas in a Separate Database Rather Than in WordPress Database

These instructions are temporarily broken because I am no longer hosting the cities.txt file. Do not use this page, for now. I will update this very soon with a working method. My apologies.

These steps will show you how to install the atlas in a separate database rather than in the WordPress database. This guide is for users who feel comfortable editing PHP files.
Why would you want the atlas in a separate database?
You may want to keep your WordPress database small in order to keep backups small. For example, if you make regular backups of your WordPress database, you do not want those to be massively increased in size by the 345 MB atlas.

Installing The Atlas

  1. First, create a new database in your hosting account. You would do this the same way you initially created a database for WordPress. Your hosting account should have an easy way for you to do this. For example, look around your hosting panel for “MySQL Databases” or “Create a New Database.” You can name the database any name.
  2. Write down the database information since you’ll need it below:
    • database name
    • database user’s username
    • database user’s password
    • database host
  3. Next, you will install the atlas into your new database. I have created a tool to do this for you. The tool is called ZodiacPress Custom Atlas Installer. Download the tool: Download atlas-installer v1.3
  4. Unzip the file you just downloaded. Inside, you will find a folder named installatlas.
  5. Inside the installatlas folder, you must edit the file named helper-db.php. To edit it, open it with any text editor such as Notepad or TextEdit.
  6. In the helper-db.php file, edit lines 13-16, which look like this:
    $database_name = '';
    $database_user = '';
    $database_password = '';
    $database_host = '';

    For each line, add your database information inside the single quotes. This is the information you wrote down when you created the database above. Then, save and close the file.

  7. Upload the installatlas folder to your site’s root HTML directory.
  8. In your web browser, go to: yoursite.com/installatlas but change yoursite.com to your own domain. You should see the atlas installer, which looks like this: 


  9. On the Atlas Installer page, click the Download Data File button to complete step 2. This will copy the cities.txt file to a temporary directory on your server. This can take several minutes to complete. When it is complete, move on to the next step.
  10. On the Atlas Installer page, click the Install Atlas button to complete step 3. This will insert all of the city records from the cities.txt file into your database. This can take up to 5 minutes (more or less, depending on your server). You will be notified when it is finished like this: 


  11. When the Atlas Installer is complete, you can remove or delete the installatlas folder from your site’s root HTML directory.
  12. Now that your atlas is installed in your separate database, you have to tell ZodiacPress to use it. Because by default, ZodiacPress will look for the atlas inside the WordPress database. To tell ZodiacPress to use your separate atlas database, you have to add this bit of PHP code to your WordPress functions:
    add_filter( 'zp_atlas_db', function( $wpdb ) {
        return new wpdb( 'database_user', 'database_password', 'database_name', 'database_host' ); 
    }, 0 );
    add_filter( 'zp_atlas_separate_db', '__return_true', 0 );
    (See how to add code to your WordPress site.)

    You must only edit line 3. Replace database_userdatabase_passworddatabase_name, and database_host with your own database details.
    NOTE: If your separate database has the same database useruser password, and database host as your WordPress database, you can use the predefined constants from wp-config.php to avoid hardcoding this information. In this case, line 3 would become:

    return new wpdb( DB_USER, DB_PASSWORD, 'database_name', DB_HOST );

    …and you would only replace database_name with the name of your separate database. The other constants on that line would remain as is.

  13. Your atlas is now completely installed. To make sure everything is working properly, go to your WordPress dashboard > ZodiacPress > Settings, and click the Misc tab. In the Atlas Status box, the “Status” row should say Active like in this image: