In this article I want to cover general pages. You create pages in the back-end ‘Pages’. General pages are just displaying contents.
Download Page
Whereas ‘Contact’, ‘Checkout’ and ‘Shopping cart’ page need to have reCaptcha, form or other functions. So they don’t belong to general pages.
Adding content to pages
Dump the following dummy text or you can add some contents through ‘Create pages’ in the back-end. Don’t forget to add the Page URI. Page URI must be one word or with under-score ‘_’.
For example, instead of ‘contact us’, it should be ‘contact_us’.
INSERT INTO `omc_page` (`id`, `name`, `keywords`, `description`, `path`, `content`, `status`, `category_id`) VALUES (25, 'Web shop', '', '', 'webshop', '<h1>Your heading here.</h1>\n<h2>Content from weshop page in the back-end</h2>', 'active', 0), (26, 'About us', '', '', 'about_us', '<h2>About us</h2>\n<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames c dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursuAliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>', 'active', 0), (27, 'Product information', '', '', 'productinformation', '<h2>Product information</h2>\n<p>Thunder, thunder, thundercats, Ho! Thundercats are on the move, Thundercats are loose. Feel the magic, hear the roar, Thundercats are loohunder, l the magic, hear the roar, Thundercats are loose. Thunder, thunder, thunder, Thundercats! Tundercats! Thundercats!</p>\n<p> </p>\n<h2>More information</h2>\n<p>Thunder, thunder, t thunder, thunder, Thundercats! Thunder, thunder, thunder, Thundercats! Thunder, thunder, thunder, Thundercats! Thundercats!</p>', 'active', 0), (28, 'Shopping guide', '', '', 'shopping_guide', '<h1>Shopping guide</h1>\n<p> </p>\n<p>Top Cat! The most effectual Top Cat! Who''s intellectual close friends get to call him T.C., providing it''s with dignity. Top Cat! The indisputable leader of the gang. He''s the boss, he''s a pip, he''s the championship. He''s the most you do. Ulysses - like a bolt of thunder from the blue. Ulysses - always fighting all the evil forces bringing peace and justice to all.</p>', 'active', 0), (29, 'Gift card', '', '', 'gift_card', '<h2>Gift card</h2>\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendreritollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.</p>', 'active', 0), (30, 'Shipping', '', '', 'shipping', '<h2>Shipping information</h2>\n<div id="short-para" class="content" style="display: block;">\n<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.</p>\n<p> </p>\n<p>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.</p>\n<p> </p>\n<p>Sed adipiscing ornare risus. Morbi est est, blandit sit amet, sagittis vel, euismod vel, velit. Pellentesque egestas sem. Suspendisse commodo ullamcorper magna.</p>\n</div>', 'active', 0), (33, 'News', '', '', 'news', '<h2><span style="font-size: 11pt; color: #800000;">News <br /></span></h2>\n<p> </p>\n<p>Ulysses, Ulysses - Soaring through all the galaxies. In search of Earth, flying in to the night. Ulysses, Ulysses - Fighting evil and tyranny, with all his power, and with all of his might. Ulysses - never call me Jack or James, I will sing my way to fame, Barnaby the Bear''s my name.</p>', 'active', 0), (35, 'Contact us', '', '', 'contact_us', '<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>', 'active', 0), (38, 'Go to checkout', '', '', 'checkout', '', 'active', 0);
Adding menu items
The next we need to do is to add some menu items.
I created menus as follows.
Dump the following to db.
Or alternatively you can add some menu items through ‘Create Menu’ in the back-end.
Don’t forget to select one of ‘Page you want to show.(URI)’ from the drop-down.
INSERT INTO `omc_menu` (`id`, `name`, `shortdesc`, `page_uri`, `status`, `parentid`, `order`) VALUES (107, 'Webshop', '', '0', 'active', 0, 20), (112, 'Webshop', '', 'webshop', 'active', 107, 10), (113, 'About', '', 'about_us', 'active', 107, 20), (114, 'Shopping guide', '', 'shopping_guide', 'active', 107, 30), (115, 'Product information', '', 'productinformation', 'active', 114, 10), (116, 'Gift card', '', 'gift_card', 'active', 114, 20), (117, 'Shipping', '', 'shipping', 'active', 114, 30), (118, 'Payment', '', '0', 'inactive', 114, 40), (120, 'About copyright', '', '0', 'inactive', 114, 60), (121, 'Products', '', '0', 'inactive', 107, 40), (122, 'News', '', 'news', 'active', 107, 50), (124, 'Contact us', '', 'contact_us', 'active', 107, 70), (125, 'Go to checkout', 'shopping cart', 'checkout', 'active', 107, 80);
Back-end menu home
You will see something similar to this image in the back-end menu home page.

Controller: function pages
You need to add the followings to modules/webshop/controllers/webshop.php
$path is the last segment of uri, for example http://myshop.com/index.php/webshop/contact, $path is contact.
If a path is the same as the folder name, in our case webshop, it redirects to it’s index.
If a path is the same as ‘contact_us’, it redirects to the contact page.
Please note the line of ID 113 About in the following image.

As you can see above, ‘about_us’ is coming from Page URI of About. And we are going to use it next.
If you have different URI for these pages, you need to replace them accordingly.
function pages($path){
if($path==$this->lang->line('webshop_folder')){
redirect('','refresh');
}elseif($path =='contact_us'){
redirect($this->lang->line('webshop_folder').'/contact','refresh');
}elseif($path =='cart'){
redirect($this->lang->line('webshop_folder').'/cart','refresh');
}elseif($path =='checkout'){
redirect($this->lang->line('webshop_folder').'/checkout','refresh');
}else{
$page = $this->MPages->getPagePath($path);
if (!empty($page)){//$page will return empty array if there is no page
$data['pagecontent'] = $page;
$data['title'] = $this->lang->line('webshop_shop_name')." | ".$page['name'];
}else{
// if there is no page redirect
redirect($this->lang->line('webshop_folder').'/index','refresh');
}
$data['page'] = $this->config->item('backendpro_template_shop') . 'page';
$data['module'] = $this->lang->line('webshop_folder');
$this->load->view($this->_container,$data);
}
}
For ‘Contact us’, ‘Shopping cart’ and ‘Checkout’, a visitor will be redirected to each function.
Otherwise $this->MPages->getPagePath($path); will pull the page content as an array.
Views page
views/shop/page.php is very simple. It echo out it’s content.
<?php echo $pagecontent['content']; ?>

By now you should have a main navigation with a drop-down menu and page contents for each page.






























[...] Codeigniter shopping cart v1.1 Part 13: general pages [...]
Shinokada,
I have this question:
Without BeP how much work would be needed to code the backend of this shopping cart?
I really like the idea of using a pre-build admin backend, but I have the feeling of skiping the best parts to learn CI.
I’m a total noob to CI but thanks to your tutorials I’ve learnt a lot so far.
It would be really nice if after yo finish this series you could post some tutorials about templating, or using Modular Separation… things that I’m trying to understand.
Thanks again for your superb work.
@Carlos: You might be interested to see v1.0 which does not have BeP.
[...] Codeigniter shopping cart v1.1 Part 13: general pages [...]