Welcome Guest, Not a member yet? Register   Sign In
Code Igniter noob :)
#11

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

i think my biggest problem is to understand how to build a website according to codeigniter framework. I heard about integrating joomla and ci, but IMO it is sense less to buying a used car while having all parts needed to build new one in garage.

I will take a look into your files, big thanks i think it is easier to learn how to build website by viewing the source of made one.
#12

[eluser]Mr. Gibon[/eluser]
hey,
totalshopuk


can you help me figure out why your shop system is redirecting me to www.localhost.com while basepatch is set to http://localhost ?
#13

[eluser]Total Shop UK[/eluser]
Sure it's the .htaccess file, comment out the lines below

Code:
# RewriteCond %{HTTP_HOST} !^www\.
# RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
#14

[eluser]Mr. Gibon[/eluser]
totalshopuk, can you describe in few words how the site is build?
I mean the main structore, where you request data, through what files is data going into template, and how template is generated?

I'm shocked, your shop is very great job!
#15

[eluser]Total Shop UK[/eluser]
In short there are two main file for the template, top and bottom.

Top contains
Banner, Top Navigation, Left Side

Bottom contains
Right Side, Bottom Navigation, Footer

The dynamic content goes in the middle.
Code:
<?php if (!isset($meta)) $meta=''; echo modules::run('_main/top',$meta); ?>
[content here]
<?php echo modules::run('_main/bottom'); ?>

Every data request uses Ajax - Login Example
Code:
function login(){
    var username = URLEncode(document.getElementById('username').value);
    var password = URLEncode(document.getElementById('password').value);
    var poststr = 'username='+username+'&password;='+password;
    ajax('/_ajax/login', 'login_status', poststr, 'POST', '', check);
}
function check(){
    var check = document.getElementById('login_status')[removed];
    if (check==1){
        document.getElementById('login_box').style.display="none";
        parent.location="/";
    }else{
        document.getElementById('login_check').className="error";
        document.getElementById('login_check')[removed]="Invalid Login!";
    }
}

Controller _ajax
Code:
function login(){
    $data = array();
    if ($this->input->post('username')!='' && $this->input->post('password')!=''){
        $user = $this->db->escape($this->input->post('username'));
        $pass = $this->db->escape($this->input->post('password'));
        $query = $this->db->query("SELECT user_id, user_level FROM users WHERE user_username=$user AND user_password=$pass AND user_active=1");
        if ($query->num_rows()>0){
            foreach ($query->result() as $key => $row){
                $id     = $row->user_id;
                $level    = $row->user_level;
            }
            $this->session->set_userdata('user_id', $id);
            $this->session->set_userdata('user_level', $level);
            $data['msg'] = 1;
        }else{
            $data['msg'] = 0;
        }
    }else{
        $data['msg'] = 0;
    }
    $this->load->view('_ajax/_blank.php',$data);
}

Hope this helps a little.
#16

[eluser]Mr. Gibon[/eluser]
I'm back,

after long research, and almost switch to joomla, i decided to write website in ci.

Question how to

Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
         parent::Controller();
    }
    
     function index()
    {
        $data['title']  = 'Tytul mojej strony';
        $data['menu']  = '<a href="http://intype.info/">Link 1</a>
<a href="http://intype.info/">link 2</a>';
        $data['content']  = '<h2>Lorem ipsum</h2>Lorem ipsum dolor sit amet.';
        $data['sidebar']  = '<a href="http://intype.info/" title="Intype" target="_blank">link</a><br /><a href="http://intype.info/" title="Intype" target="_blank">link</a>';
        $data['footer']  = 'Copyright 2010 by Me :)';
        $this->parser->parse('page', $data);  
    }
    function about()
    {
    
    $this->parser->parse('page', $data);  
    
    }
}

how to pass $data form controller/index to controller/about ?
(In future values will be taken form DB)
Is it a good way to build website?
#17

[eluser]Tominator[/eluser]
Hi Mr. Gibon!

Use this: http://ellislab.com/forums/viewthread/153269/

You can make it super easy:

ver 1.3:

PHP:
Code:
$id = 5; // you probably get this value from URI, or DB ...

$query = $this->db->get_where('page', array('id' => $id));
$data = $query->row_array();

$this->load->library('parser');
$this->parser->parse('your_template', $data);

TPL (your_template.tpl):
Code:
&lt;html&gt;
&lt;head&gt;
&lt;meta autor="{autor}"&gt;
&lt;meta description="{desc}"&gt;
&lt;meta keywords="{keywords}"&gt;

{value}

&lt;/head&gt;
&lt;body&gt;

<div id="banner">
&lt;!-- INCLUDE banner --&gt;
</div>
<div id="content">
{content}
</div>
<div id="sidebar">
&lt;!-- INCLUDE sidebar --&gt;
</div>

<div id="footer">
&lt;!-- INCLUDE footer --&gt;
</div>
&lt;/body&gt;
&lt;/html&gt;

Is it cool, isn't it? Big Grin
#18

[eluser]Mr. Gibon[/eluser]
Sounds great, but what is the big difference between the build-in praser, and yours?

However is it a good way to build website in one controller ( site/index , site/offer, site/contact etc etc)??
#19

[eluser]Tominator[/eluser]
Good question. There are some advantages:
1. It's got better system of replacing pseudo-varibales and cycles
2. It supports conditions and includes
3. It supports dynamically nested cycles too
4. Providing final solution for theming your page and accesing css/js/img ...
#20

[eluser]Mr. Gibon[/eluser]
Thanks for reply, i will probably use this Parser.

Still no answer for this: Is is a good way of building website based on code igniter, all in one controler like this

Code:
class Welcome extends Controller {

    function Welcome()
    {
     content here
    }
        function Offer()
    {
     content here
    }
    function Contact()
    {
     content here
    }




Theme © iAndrew 2016 - Forum software by © MyBB