Building a Twitter Bootstrap template
The following is a guide for creating a Soholaunch template with Twitter Bootstrap.
Here’s the complete working template file that this guide uses: http://site.soholaunch.com/media/bootstrap-basic-gray.zip
Feel free to download it and use it.
Main getting started steps:
- Download the CSS version of bootstrap at: http://getbootstrap.com/
- Put the zip in your template folder. Here’s the path: sohoadmin/program/modules/site_templates/pages/your_template_name. Where "your_template_name" is the folder name that will contain your template. Then extract the zip in there.
- Add an index.html file. As of this writing, a default index.html doesn’t come with the zip, but Bootstrap’s example templates are here, under “examples”: http://getbootstrap.com/getting-started/
- If using one of their templates, open one in your browser, view the source and copy and paste it into your index.html file and save it in your template folder. This guide uses the “Jumbotron” template.
- Add the #relative_template_path# pound variable to any links to Bootstrap’s default stylesheets.
- Add the pound variables, a custom.css file, and then start making your template.
(that is, not the Less or Sass versions. You can use Less or Sass, but this guide covers using the CSS version for now)
The main things the menu needs are certain css classes added to different elements. Copy the pgm-auto_menu.php found inside the zip file at the top of this doc, and paste it into your template folder. We added the required classes to it to make the menu work (like collapse into the “hamburger” icon, and retain all the drop-down menu items).
Add the #hmains# pound variable into the correct place in index.html for the menu. It’s usually where the template starts building out the menu with unordered list items (i.e. ul’s and li’s).
Our index.html and commentary
If you take a look at the index.html file in our template zip, you'll see we made a few changes. We had to change a few things from the Jumbotron template code that we copied and pasted. Below are the main highlights so you don’t miss anything:
- At the bottom, the main javascript file link had a path like ../../js/bootstrap.min.js . Remove the ../../ so it’s just js/bootstrap.min.js, or else it won’t be applied. In other words, match the folder structure you have.
- There is no “jumbotron.css” stylesheet in the get bootstrap download zip, so we just deleted that link in our index.html. Plus we deleted other items that didn't come with the zip file, like the link to a favicon, etc.
- We commented out any forms that came with the template. Soholaunch lets you drag and drop login and search boxes already in the page editor. But you can still use them if you need to.