Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
In this course, author Joseph Lowery shows how to create a robust WordPress-based site using Dreamweaver. The course lays out the essentials of planning a site, explains how to implement custom sidebars, and demonstrates building page templates. The course also explains how to integrate PHP functionality and extend the WordPress database.
All of the posts, pages, settings and even user details for a WordPress- driven site are stored in a MySQL database, established when you first install WordPress. For the most part, this is a seamless invisible operation, so much so you may forget that you've got a fully functioning database at your disposal. In this chapter, we'll take a look at one of the ways you can leverage that database and Dreamweaver's code- writing prowess to include dynamic data from your own database tables in your WordPress pages.
Let's start with creating a new table in the WordPress-created database. So, I am going to switch over to phpMyAdmin, which I've invoked from WAMP server, and I'll choose my database, tpa, and then select SQL. Now I can paste in any SQL here that I want. I had previously developed a SQL table and then exported that file. It's now stored as planets.sql, located in the Exercise Files, under Chapter 5, 05_01.
So let's go into Dreamweaver and pick that up. Now you could import it, but I want to show you the code first before we bring it in. There is the code. When you're moving from one database to another it's always better to copy the code and paste it into your SQL field rather than inserting an entire file, because quite often the database names that you see here on line 19 are different. In this case, they're the same, but I've stumbled on that block many a time.
So I am going to select everything, doing a Ctrl+A, Command+A on the Mac, and then copy it, and now let's head back to phpMyAdmin and do a Ctrl+V or Command+V to paste it in. Now I am going to scroll back up to the top. And just as a reminder, this is the value that you want to double-check. You'll see up here it will say "Run SQL query/queries on database" and then the name of the database. And if it's not the same, you'll need to change this value where it says database tpa.
I think we're good. Let's go ahead and click Go. It's in the lower right here. After you've clicked Go, click on Structure and you'll see planets listed there as the new table. You can also go over to the little refresh here and reload your navigation frame and you'll see planets there. With the data in a new database, we're ready to create a new database connection in Dreamweaver. So back to Dreamweaver. I'll close my planets.sql file. Now I'll need to drop out of Live view in order to access the proper panel.
So I'll toggle Live View off and then go to Window > Databases, and once I have that, I'll click on adding a new connection. Select MySQL Connection and then I am going to give it a name of connTPA, because we can use this connection to access all the tables that we'll need for the site, not just the single one we inserted. In the MySQL server field, enter the name of your server-- in our case, it's localhost--and then the user name, which is root. You'll call that there was no MySQL password set up. And now let's choose our database.
There is tpa. Click on OK. You can go ahead and click Test if you like. Dreamweaver will pick up on the fact that we haven't specified a password. In this case it's okay because we are not a production environment at the moment. And I'll click OK. And there is our new connTPA. And if I expand that and then expand Tables, we'll see our planets table, along with all of the other WordPress tables. Now also, if I expand my Files panel and scroll up to the top, you'll see the Connections folder that we have here.
This is the standard way the Dreamweaver works with connections. It puts a folder in the site root. There are a couple of ways that we can use this connection in our WordPress template pages, but the standard technique isn't one of them. The quickest way I've found is to simply copy the connections folder, with the PHP file that was created within it, to our theme folder. So I am going to right-click on Connections, choose Edit > Copy, and then go down to our theme folder and right-click again, Edit > Paste.
Of course, you can use the keyboard shortcuts if you want. You should see down at the bottom there for the moment, the Connections folder. If I expand it, there is our connTPA.php file. Dreamweaver has just refreshed, so it's put it back up at the top. Now that the Connections folder has been transferred, you're ready to create a recordset and apply it to a WordPress template file. I'll show you how in this chapter's video "Including a recordset."
There are currently no FAQs about Dreamweaver and WordPress: Building Sites.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.