• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Igniter noob :)

[eluser]Mr. Gibon[/eluser]
Hello all!

I wonder if you could help me. I'm consider building website based on Codeigniter, but after 2 weeks of research and tutorials of Jeffrey Way ( great job Wink ) cannot find solution (example) of dinamic template version.

What I want to get is header,footer, and other additional parts of web contain info form database.

I'm not sure if havin one controller and tons of functions for everypage is the idea of CI, same as loading lots of same things every other controller (if singel controller is a single page).

If you may share with any structure, or existing template tell me yours thoughts about it.


[eluser]Total Shop UK[/eluser]

I used HMVC to resolve the problem.

application > modules > _main > controllers > _main.php

application > modules > _main > views > _top.php
application > modules > _main > views > _bottom.php

You can download my code here http://sourceforge.net/projects/totalshopuk/files/

HMVC http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/

You want to extend the controller and then put the code to get sutff for header footer etc in that instead of the actual controller.

i.e. create a file called "MY_Controller" in the libraries folder.

put this in the file
class MY_Controller extends Controller
    public $header;
        public $footer;
    function __construct()
                $this -> header = // The header you want to have, e.g. from database or otherwise

Then in all of your controllers instead of them having a parent of "Controller" you have a parent of MY_Controller i.e.
class Home extends MY_Controller
    function __construct()
$header = $this -> header; // This gets the varaible you assigned to the header in the my_controller file

// all of the sutff you want to do.
This way every single one of your pages has access to the variable $this -> header

[eluser]Mr. Gibon[/eluser]
Thanks for reply,

What solution would you choose for dynamic template?

I mean dynamic meta tags, content as $value form a array or database.

for example different set of colours, banners, meta tags, or even css for mydomain.com/page2

I want the template to be modular and easy to edi evey single module display, and code.

well i'm not expert, and php new for me, but i want to get someting similar to:
<meta autor="$value">
<meta description="$value">
<meta keywords="$value">
<?php echo='$value'; ?>

<div id="banner">
&lt;?php include'template/banner.php'; ?&gt;
<div id="content">
&lt;?php echo='$content'; ?&gt;
<div id="sidebar">
&lt;?php include'template/sidebar.php'; ?&gt;

<div id="footer">
&lt;?php include'template/footer.php'; ?&gt;
( including jquery, ajax, javascript and so on...)
considering different table in sql for settings of site, and other for contents, and another one for components.

What is the best way to get it in CI without any very advanced solutions?

[eluser]Phil Sturgeon[/eluser]
Modular Extensions is no longer supported, and I am pretty sure your MY_Controller methods will just confuse the man for now.

Use Modular Separation if you want any sort of HMVC system, and I would recommend my Template library to handle your layouts. It's a very simple solution with lots of power available.

[eluser]Total Shop UK[/eluser]
[quote author="Mr. Gibon" date="1271878330"]Thanks for reply,

What solution would you choose for dynamic template?

I mean dynamic meta tags, content as $value form a array or database.

If you check out my code at SourceForge you can see the full code but the below snippets show you how it works..

&lt;?php if (!isset($meta)) $meta=''; echo modules::run('_main/top',$meta); ?&gt;

if ($meta!=''){
      $data['content'] = $this->content->get_content('home');
$this->load->view('_top.php', $data);

&lt;meta name="description" content="&lt;?php echo $meta['description']; ?&gt;"&gt;
&lt;meta name="keywords" content="&lt;?php echo $meta['keywords']; ?&gt;"&gt;

[eluser]Phil Sturgeon[/eluser]
Case and point.


$this->template->title( 'Title' )        
            ->set_metadata('keywords', 'keywords, stuff' )
            ->set_metadata('description', 'really easy template library' )
            ->build('page', $data);

Is much nicer syntax, and does not break MVC patterns as much as Modular Extensions?

[eluser]Total Shop UK[/eluser]
I think I'll research Modular Separation as I agree it does look much better, I just always used Modular Extensions because they worked for me.

[eluser]Mr. Gibon[/eluser]
totalshopuk, please give me link to your sourceforge.

Template liblary is a bit too advancet for me, i'm starting my advernture with php/ci.

Can you show me your solutions?

All tuts on the web are showing how to create single pages, functions, controllers, but i haven't found anything how to create dynamic website with adminstration panel with dynamic template.

I'm looking for smothing simple scalable, and secure Smile

[eluser]Total Shop UK[/eluser]
SF - http://sourceforge.net/projects/totalshopuk/files/

I use the code in my eCommerce project as a basis for all my web apps.
By just stripping out the code I don't need and adding additional.

As it uses HMVC, Ajax, CMS etc.. I can use it for all sorts of development work.

Let me know if you need any additional help.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.