Your .htaccess file should be ready to rock but, if this is a new install of this framework, you may need to change your base path. Just swap "framework" on line 2 for whatever your real base path is:
RewriteEngine On RewriteBase /framework/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]
Your site config is held in the /lib/config.inc.php file - make any changes you need in these lines:
define("BASE_PATH","http://127.0.0.1"); //The root domain for your site $path = "/framework"; //The folder where your site is held (site root) //Define site URLs define("SITE_URL",BASE_PATH.$path); define("ASSETS_URL",BASE_PATH.$path.'/assets'); //The folder, from the site root where assets are held define("SITE_NAME",'framework'); //Your site name define("SITE_AUTHOR",'Dave Waller'); //Your name, as the site owner define("SITE_EMAIL",'site@d13design.co.uk'); //A contact email address define("DB_HOST",'127.0.0.1'); //Your database host define("DB_NAME",'d13design'); //The name of your database define("DB_USER",'root'); //Your database user name define("DB_PWRD",'root'); //Your database password define("TBL_PRE",''); //Your database table prefix for this site define("SALT",'vXjaNwrIpwOuqMEq'); //Your security salt - replace this with a 16 digit random alpha string define("ALLOW_REGISTER",true); //Can users register - leaving this set to true can be dangerous define("TEMPLATE",'default'); //The site template to use - the folder name of the template within the "template" folder define("PAGE_COUNT", 3); //The number of items to show per page when using pagination
You can add images to your codse using the simple html_img helper:
<?php html_img('filename', 'imageClass', 'altTag', 'linkURL', 'linkClass', 'title', 'target'); ?>
This assumes that images are stored in your assets folder, as defined by your ASSETS_URL config setting.
You can add links to your code using the simple html_link helper:
<?php html_link('linkURL', 'linkText', 'linkClass', 'title', 'target', 'span'); ?>
You can generate internal paths using the create_path helper:
<?php create_path('section', 'page', 'content'); ?>
<?php html_link(create_path('blog', '2011-08', 'hello-world'), 'Read my blog post!'); ?> <a href="http://127.0.0.1/d13design/blog/2011-08/hello-world">Read my blog post!</a>
You can convert a PHP strtotime string to a prettier date using the pretty_date helper:
<?php echo pretty_date($created_date); ?>
returns 'March 2012'
The pretty_date helper comes with 4 flavours, defaulting to 'short':
<?php echo pretty_date($created_date,'short'); ?> <?php echo pretty_date($created_date,'medium'); ?> <?php echo pretty_date($created_date,'long'); ?> <?php echo pretty_date($created_date,'x-long'); ?>
returns 'March 2012' returns '03 March 2012' returns 'Monday, 03 March 2012' returns 'Monday, 03 March 2012 - 20:53 pm'
You can trim long strings of text to a given number of words using the trimmer helper:
<?php echo trimmer('The quick brown fox jumped over the lazy dog', 8, '…'); ?>
returns 'The quick brown fox jumped over the lazy '
You can use the html_css and html_js helpers to easily add CSS and JS files to your templates:
<?php html_css('styles.css'); ?> <?php html_js('jquery.js'); ?>
<link rel="stylesheet" type="text/css" href="http://127.0.0.1/d13design/assets/css/styles.css" /> <script type="text/javascript" src="http://127.0.0.1/d13design/assets/js/jquery.js"></script>
This assumes that javascripts are stored in a js folder in your assets folder, as defined by your ASSETS_URL config setting.
This assumes that CSS is stored in a css folder in your template.
You can use the included prettify library to handle code listings:
<pre class="prettyprint linenums"> <?php $str = "Hello World"; echo $str; // Outputs Hello World ?> </pre>
<?php $str = "Hello World"; echo $str; // Outputs Hello World ?>
You can paginate through all of the content within a given section using the pagination helper (this uses the standard Twitter Bootstrap markup and styling for pagination). You can also adjust the number of items to show on a page using the PAGE_COUNT variable in your config file:
<?php pagination($pagelist,$a['section'],$a['qs'],'first','previous','next','last'); ?> //pagelist is an array of content
An example of an image linking to a page followed by a text link to an external site:
<?php echo html_img('images/sample.jpg', 'photo', 'A photo of a spider', create_path('blog','2011-08','spiders-everywhere'), 'img_link', 'Read more spiders', '_self'); echo '<br/>'; html_link('http://flic.kr/p/5q4BzT', 'View this photo on Flickr.com', 'ext_link', 'View this photo on Flickr.com', '_blank', true); ?>
<a href="http://d13design.co.uk/blog/2011-08/spiders-everywhere" title="Read more about spiders" class="img_link" target="_self"> <img src="http://d13design.co.uk/assets/images/sample.jpg" alt="A photo of a spider" class="photo" /> </a> <br/> <a href="http://flic.kr/p/5q4BzT" title="View this photo on Flickr.com" class="ext_link" target="_blank"> <span>View this photo on Flickr.com</span> </a>
You can create a list of all of the content pages in the content/pages folder using the list_pages helper:
<ul> <?php list_pages(); ?> </ul>
<ul> <li><a href="/pages/about">About</a></li> <li><a href="/pages/contact">Contact</a></li> </ul>
You can create a list of all of the content sections in the content folder using the list_sections helper:
<ul> <?php list_sections(); ?> </ul>
<ul> <li><a href="/work">Work</a></li> <li><a href="/hobbies">Hobbies</a></li> <li><a href="/family">Family</a></li> </ul>
You can get the full name of a section from its slug using the get_section helper:
<h2> <?php echo get_section('section-slug'); ?> </h2>
<h2> Section Slug </h2>
You can create a list of all recent articles using the list_articles helper:
<ul> <?php list_articles(); ?> </ul>
<ul> <li><a href="/blog/latest-post">Latest post</a></li> <li><a href="/blog/an-older-post">An older post</a></li> <li><a href="/portfolio/even-older-post">Even older post</a></li> <li><a href="/blog/almost-ancient-post">Almost ancient post</a></li> <li><a href="/discoveries/the-oldest-post">The oldest post</a></li> </ul>
This helper defaults to showing recent posts from all sections and lists up to 5 results, you can override these settings if you like:
<ul> <?php list_articles('blog',2); ?> </ul>
<ul> <li><a href="/blog/latest-post">Latest post</a></li> <li><a href="/blog/an-older-post">An older post</a></li> </ul>
You can also pass in a class name to define an icon (extends the Twitter Bootstrap icon set), defaulting to 'file':
<ul> <?php list_articles('blog',2, 'book'); ?> </ul>
<ul> <li><i class="icon-book"></i><a href="/blog/latest-post">Latest post</a></li> <li><i class="icon-book"></i><a href="/blog/an-older-post">An older post</a></li> </ul>
You can create an array that contains all of the information of a page using the get_page helper, all you have to do is pass it a valid slug:
<ul> <?php $page_data = get_page('my-sample-page'); ?> </ul>
$page_data = array( 'id' => 13, 'title' => 'My Sample Page', 'contents' => '<p>This is a sample page and contains lots of text and stuff!</p>' );
You can create an array that contains all of the information of an article using the get_article helper, all you have to do is pass it a valid slug:
<ul> <?php $article_data = get_article('latest-post'); ?> </ul>
$article_data = array( 'id' => 4, 'section_id' => 1, 'section_title' => 'Blog', 'section_slug' => 'blog', 'title' => 'Latest Post', 'slug' => 'latest-post', 'synopsis' => 'Writing is a gift that I have, this will become clear the more you read', 'contents' => '<p>This is a sample page and contains lots of text and stuff!</p>' 'created' => '4523846452', );
Using custom data field is a great way to tag more properties against your articles. You can define whatever you want in this space and then use it in your templates. The parse_properties helper is an easy way to turn your custom data into a useful array.
The helper works on a principle of key-value pairs, for instance thumb=images/thumbnail.jpg|externalLink=http://google.com
could be set as the custom data for an article. Passing this into the helper would pass back an array:
<?php $custom_props = parse_properties($article['custom_data']); ?>
$custom_props = array( 'thumb' => 'images/thumbnail.jpg', 'externalLink' => 'http://google.com' );
You can override the separators used to parse properties by adding an additional 2 parameters, these default to |
as the property separator and =
as the key-value separator.
<?php $article['custom_data'] = 'thumb#images/thumbnail.jpg~externalLink#http://google.com'; ?>
<?php $custom_props = parse_properties($article['custom_data'],'~','#'); ?>
$custom_props = array( 'thumb' => 'images/thumbnail.jpg', 'externalLink' => 'http://google.com' );
You can inlcude your latest dribbble shots using the included dribbble helper, just add the following code to your template files:
<?php $dribbble = new Dribbble(); $my_shots = $dribbble->get_player_shots('d13design', 1, 1); foreach($my_shots->shots as $shot){ echo '<a href="'.$shot->url.'" target="_blank">'; echo '<img src="'.$shot->image_url.'" alt="'.$shot->title.'">'; echo '</a>'; } ?>
You can inlcude your latest tweet using the included get_status helper, just add the following code to your template files:
<?php echo get_status('d13design'); ?>
This application template makes use of the LESS implemetation of Twitter's Bootstrap.
Built as a personal project to help kickstart website projects, this framework is offered with no warranty what-so-ever.
Do with it as you wish, just bear in mind that it isn't intended to be all powerful and it certainly isn't professionally coded.
There's tons of stuff bundled in there, including the Twitter Bootstrap, and full credits are available in the readme file.
If you find it useful or have any questions, find me on d13design.co.uk or on Twitter @d13design.