Documentation 1.x

How to create a Drag & Drop website

Detailed tutorial on how to build a Drag & Drop managed website starting from HTML / CSS design files. We will use a free HTML / CSS template as an example but you can use this tutorial to integrate ImpressPages Drag & Drop CMS into your own HTML / CSS.

Step 1 - Find the design you like

We will use free design template called “Professional” from http://www.freecsstemplates.org. Name can be smarter but it looks quite nice and HTML / CSS work is already done and it is free. We will use it to create our theme.

Design archive has:

  • Folder images - there are all required images.
  • File index.html – main HTML file.
  • File license.txt – Creative Commons license. It means that this design is free to use, but you need to leave this license file intact.
  • File styles.css – CSS styles.

Later in this tutorial we will see what exactly we need to do with them.

Step 2 - Download and install ImpressPages CMS

Now we need to install ImpressPages CMS. Later we will integrate our HTML into it.

To install ImpressPages CMS you will need a hosting solution with PHP 5.3 and MySQL. If you don’t have one, use XAMPP or EasyPHP to install Apache on your computer.

ImpressPages CMS installation steps:

  • Download the ImpressPages CMS
  • Extract downloaded files to the folder on your server where you want the CMS to be installed.
  • Login to your hosting provider and create a database. If you work on localhost you can do that using phpMyAdmin.
  • Then type appropriate URL in your browser. You will see the installation wizard. Follow the instructions until the installation completes.

By default, database host is "localhost" but with some hosting providers or software it could be "127.0.0.1". Check with hosting provider if needed.

Default login information when working with installation on your local computer (with XAMPP or EasyPHP) is "root" (without quotes) for the username and empty field for the password.

Here is a video on how to do that: http://www.impresspages.org/docs/getting-started/installation/

After a successful installation you should see a website with default design and content:

Default ImpressPages CMS installation

Step 3 - Create new theme

To integrate our custom design, we need to create a theme. It is just a folder with HTML and CSS files. So we need to create a new theme and integrate our downloaded HTML / CSS files.

In ImpressPages CMS themes are stored in folder ip_themes. By default there is one theme ip_default. Let’s create a new one. Our theme is called “professional”, so we will create new folder: professional in ip_themes, next to folder ip_default.

1. Put all your files from downloaded theme to newly created ip_themes/professional folder:

File structure

2. Copy ip_content.css from ip_default folder to professional folder. This file contains general styles used to style photo galleries, titles, contact forms and other manageable content. Later we will change it a bit to suit our needs.

3. Also copy blank.php from ip_default folder to professional folder. This file is used to generate RSS feed and other system tasks where no real HTML is involved. We don’t need to do anything with this file. It just needs to be in the theme.

4. Rename index.html file to main.php. The system looks for main.php to get the HTML for the website layout.

Now your files should look like this:

ImpressPages CMS theme file structure

Step 4 - Switch website to new theme

Now we have a new theme folder with all the required files, but we need to tell the system to use it instead of the default theme.

Open ip_config.php file. It is located in the root folder of your installation, next to other system files (see the image below).

The place of ip_config.php file in ImpressPages CMS

Use any text editor such as Notepad++ or PSPad. The line we need to change is somewhere near line 62. Replace this line:

define('THEME', 'ip_default'); //theme from themes directory

to

define('THEME', 'professional'); //theme from themes directory

This is the step where we actually tell the system to use our new theme. Now we can check our website in the browser. It should look like this:

New theme without styles

Our website has no style or design. This is because the browser can’t find the CSS files at the moment.

Step 5 - Fix CSS styles

The website uses our newly created theme, but the browser can’t find the CSS styles, because the CSS file is not in the same directory anymore.

Open ip_themes/professional/main.php file. Line 18 should include:

<link rel="stylesheet" type="text/css" href="style.css" media="screen" />

We need to change this line to:

<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL.THEME_DIR.THEME; ?>/style.css" media="screen" />

What happened here is that we pointed to the exact place where the CSS file is located. The PHP code will replace BASE_URL with your actual website URL (in our case www.example.com), THEME_DIR with “ip_themes” and THEME with “professional”. As a result the browser will get a full URL to the CSS file: http://www.example.com/ip_themes/professional/style.css

Look at our website. It is beautiful now.

New theme preview with static content

Step 6 - Menu integration

The links on our website don’t work yet. It is just one static page. We need to replace the static hardcoded menu code to PHP code that will generate a menu from the database.

Open main HTML file ip_themes/professional/main.php again and change lines 31 - 37:

<ul>
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact Us</a></li>
</ul>

to PHP code that generates menu:

<?php
        require_once (BASE_DIR.LIBRARY_DIR.'php/menu/common.php');
        $menuTop = new Library\Php\Menu\Common();
        echo $menuTop->generateSubmenu('top', null, 1); //$zoneName, $parentElementId, $depthLimit
?>

Now we have our top menu working. Let’s do the same with menu on the left. Change lines 86 – 109:

<li>
  <h2>Lorem Ipsum</h2>
  <ul>
    <li><a href="#">Fusce dui neque fringilla</a></li>
    <li><a href="#">Eget tempor eget nonummy</a></li>
    <li><a href="#">Magna lacus bibendum mauris</a></li>
    <li><a href="#">Nec metus sed donec</a></li>
    <li><a href="#">Magna lacus bibendum mauris</a></li>
    <li><a href="#">Velit semper nisi molestie</a></li>
    <li><a href="#">Eget tempor eget nonummy</a></li>
  </ul>
</li>
<li>
  <h2>Volutpat Dolore</h2>
  <ul>
    <li><a href="#">Nec metus sed donec</a></li>
    <li><a href="#">Magna lacus bibendum mauris</a></li>
    <li><a href="#">Velit semper nisi molestie</a></li>
    <li><a href="#">Eget tempor eget nonummy</a></li>
    <li><a href="#">Nec metus sed donec</a></li>
    <li><a href="#">Magna lacus bibendum mauris</a></li>
    <li><a href="#">Velit semper nisi molestie</a></li>
  </ul>
</li>

to PHP code that generates left menu:

<li>
  <h2>Services</h2>
<?php
        require_once (BASE_DIR.LIBRARY_DIR.'php/menu/common.php');
        $menuTop = new Library\Php\Menu\Common();
        echo $menuTop->generateSubmenu('left', null, 1); //$zoneName, $parentElementId, $depthLimit
?>
</li>

Now we have our menu working. We see default ImpressPages CMS menu items: Welcome, Lorem ipsum, Text, Photos, Video and other.

New theme with dynamic menu

Step 7 - Output content of the page

Now regardless the page we are visiting, we always see the same content: “Welcome to our website …”. We need to replace that content in our template to PHP code that will generate actual page content.

Open ip_themes/professional/main.php file and replace lines 43 – 69:

<div class="post">
	<h1 class="title">Welcome to our website </h1>
	<p class="byline"><small>Posted by FreeCssTemplates</small></p>
	<div class="entry">
		<p><strong>Professional 1.0 …  Enjoy :)</p>
	</div>
…
…
…
	<div class="meta">
		<p class="links"><a href="#" class="comments">Comments (32)</a>  •   <a href="#" class="more">Read full post »</a></p>
	</div>
</div>

to PHP code that generates actual page content:

<div class="ipContent">
  <?php echo $site->generateContent(); ?>

  <div class="clear"><!-- --></div>
</div>

Generated content requires additional styles. We can write them from scratch but it is easier to use the skeleton from the ip_content.css file. So, add a new line in head section of main.php file. It will tell the browser to include those CSS styles and use them to style content: text, titles and photos. Open ip_themes/professional/main.php and add new line somewhere near the line 18 before </head>:

<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL.THEME_DIR.THEME; ?>/ip_content.css" media="screen" />

Now we can navigate through our website and see real content.

New theme with dynamic content

Step 8 - Fix title styles

Our content looks more like the default ImpressPages CMS installation and does not suit the whole website style. That is because content styles in ip_content.css override styles, described in style.css. So we need to copy some styles from site.php to ip_content.css. The title styles in style.css are described on line 146:

.post .title {
	margin: 0px;
	background: #444444 url(images/img02.jpg) no-repeat left 50%;
	padding: 7px 25px;
	font-size: 1.4em;
}

We need to copy these lines to ip_content.css. Then titles will look like they should. But in ip_content.css file we have three title styles: H1, H2, H3. So we will paste the same styles three times changing the size of font. To do that we need to replace lines 155 – 181 of ip_themes/professional/ip_content.css to

.ipContent h1.ipWidgetTitleHeading {
  margin: 0px;
  background: #444444 url(images/img02.jpg) no-repeat left 50%;
  padding: 7px 25px;
  font-size: 1.4em;
}

.ipContent h2.ipWidgetTitleHeading {
  margin: 0px;
  background: #444444 url(images/img02.jpg) no-repeat left 50%;
  padding: 7px 25px;
  font-size: 1.2em;
}

.ipContent h3.ipWidgetTitleHeading {
  margin: 0px;
  background: #444444 url(images/img02.jpg) no-repeat left 50%;
  padding: 7px 25px;
  font-size: 1.0em;
}

Also, the list styles described in ip_content.css don’t suit our current style. We will just remove unnecessary styles and leave the default browser list styles. Remove these lines from ip_themes/professional/ip_content.css file near line 94:

.ipContent ul,
.mceContentBody ul {
  list-style: none;
  margin: 10px 0 10px 15px;
  padding: 0;
}

.ipContent ul li,
.mceContentBody ul li {
  background: transparent url(images/list.gif) no-repeat scroll 6px 9px;
  line-height: 20px;
  margin: 0;
  padding: 0 0 0 18px;
}

Now our website content looks good. Press ctrl + F5 to force refresh if what you see is not like the picture:

New ImpressPages CMS theme is ready

Step 9 - Content management

The administration area will not work until you add the required JavaScript to the head section of the layout file. Open ip_themes/professional/main.php file and add this line before </head> near line 20.

<script src="<?php echo BASE_URL.LIBRARY_DIR; ?>js/default.js"></script>

Now you can login using this address: http://www.example.com/admin.php and the credentials that you used in the installation process.

Watch the video how to manage content: http://www.impresspages.org/docs/using-impresspages/content-management/

Step 10 - Images

Default image settings don’t match the layout width. That’s why the photo gallery has additional space at the right and the big photo goes out of the page.

How to fix image sizes

We need to sign in to administration panel and change photo cropping parameters to fit our new style. Change a single photo width:

  • add admin.php at the end of your website URL (http://www.example.com/admin.php) and login.
  • go to tab Developer -> Modules config
  • click Content management on the left if it's not selected
  • press yellow folder icon on line Widget: Photo
  • change Photo width parameter value to 562

Change photo gallery cropping width and height:

  • go to tab Developer -> Modules config
  • click Content management on the left if it's not selected
  • press yellow folder icon on line Widget: Photo gallery
  • change Photo width parameter value to 127
  • change Photo height parameter value to 100

Additionally you can change the Big photo width and Big photo height parameters. They describe the size of large version of photo that is visible in popup.

Now the photos will be cropped correctly. But you need to delete old photos and add new ones because settings apply only to new images.

Browse through all other parameters to understand what you can change to better accomodate your needs. Or read more about widgets configuration.

Step 11 - Lightbox

Now when we press image it opens in separate window. Follow the instructions bellow to install a JavaScript lightbox. It will show your large images in a beautiful lightbox.

Open ip_themes/professional/main.php file and add new line before </head>. This line includes required CSS styles:

<link rel="stylesheet" href="<?php echo BASE_URL.LIBRARY_DIR; ?>js/lightbox/css/lightbox.css" type="text/css" media="screen" />

Then add these lines at the end of ip_themes/professional/main.php file before </body> line.

<!-- popups -->
<script type="text/javascript" src="<?php echo BASE_URL.LIBRARY_DIR; ?>js/lightbox/js/prototype.js"></script>
<script type="text/javascript" src="<?php echo BASE_URL.LIBRARY_DIR; ?>js/lightbox/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="<?php echo BASE_URL.LIBRARY_DIR; ?>js/lightbox/js/lightbox.js"></script>
<script type="text/javascript">
  // <![CDATA[
  LightboxOptions.fileLoadingImage = '<?php echo BASE_URL.LIBRARY_DIR; ?>' + 'js/lightbox/images/loading.gif';
  LightboxOptions.fileBottomNavCloseImage = '<?php echo BASE_URL.LIBRARY_DIR; ?>' + 'js/lightbox/images/closelabel.gif';
  //]]>
</script>
<!-- spopups -->

It is a JavaScript that will handle mouse events and show large version of image. Now our images open like that:

Lightbox in ImpressPages CMS

Step 12 - Search box

The search box does not work. It is just a static HTML form. We need to replace it with a functional search box, generated by ImpressPages CMS.

To make search field to work, open ip_themes/professional/main.php file and replace the code below (near the lines 70 – 75):

<form method="get" action="">
  <fieldset>
  <input type="text" id="s" name="s" value="" />
  <input type="submit" id="x" value="Search" />
  </fieldset>
</form>

with:

<?php
  echo $site->getZone('search')->generateSearchBox();
?>

ImpressPages CMS generated form looks different. That’s why we need to change CSS styles to adapt the search box to our new design. Open ip_themes/professional/style.css and add these lines at the bottom:

.modAdministratorSearchInput {
  margin-left: 20px;
  float: left;	
}

.modAdministratorSearchButton {
  background: #444444 url(images/img02.jpg) no-repeat -3px 50%;
  margin-left: 10px;
  width: 22px;
  height: 22px;
  text-size: 1px;
  float: left;
}

#search {
  height: 90px;	
}

Now your search box looks fine. If not, press ctrl + F5 to force refresh.

New theme with dynamic search box

Step 13 - Logo

The logo has no link. Usually logo links to home page of website. Let’s do that. Open ip_themes/professional/main.php and replace line 29:

<h1><a href="#">Professional</a></h1>

to

<h1><a href="<?php echo $site->generateUrl(); ?>">Example.com</a></h1>

If you would like to replace the text with a logo image (for example your_logo.gif), upload it to ip_themes/professional/imges/ directory and replace line:

<h1><a href="#">Professional</a></h1>

to

<a href="<?php echo $site->generateUrl(); ?>"><img src="<?php echo BASE_URL.THEME_DIR.THEME; ?>/images/img03.jpg" /></a>

You can change img03.jpg with any other image that is relevant to you, like your_logo.png.

Now you have your new website with new design. You can start dragging and dropping the content. Hope you like it.

Write a comment

You must be logged in to comment.