Welcome Guest, Not a member yet? Register   Sign In
  using a single controller?
Posted by: El Forum - 10-13-2007, 05:31 PM - No Replies

[eluser]michaelp420[/eluser]
Hi,

I've been trying and trying to get my current CI setup to use a single controller but i cannot and am now asking for your help. Quick overview...i've got a site created that currently has the following controllers:
controllers/
--about.php
--misc.php
--news.php
--living.php
--template_engine.php

The associated views for the four controllers reside in the views directory with the fiels for each in a separate subdir:
views/about/index.inc
views/about/about_us.inc
views/about/contact.inc

...etc. This same sort of structure is used for a subdirectory for each controller. I have a template class that is included in each controller (see below) that actually builds the pages based on the content chosen by the specific page requested. I'm going to abbreviate for simplicity sake but here is the about.php controller:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

// This is important
require_once('template_engine.php');

class About extends TemplateEngine {
    
    function About()
    {
        parent::TemplateEngine();
        parent::set_section('pagetitle','| '.$this->Nav->section_title(), 'APPEND');
    }
    
    function index()
    {
        // Set page title
        parent::set_section('pagetitle', '', 'APPEND');
        
        // Set as main contents
        parent::set_section('content', $this->load->view('about/index.inc', '', true));
        // build the template
        parent::build_template();
    }
        
       function about_us()
    {
        // Set page title
        parent::set_section('pagetitle', '', 'APPEND');
        
        // Set as main contents
        parent::set_section('content', $this->load->view('about/about_us.inc', '', true));
        // build the template
        parent::build_template();
    }

        function contact()
    {
        // Set page title
        parent::set_section('pagetitle', '', 'APPEND');
        
        // Set as main contents
        parent::set_section('content', $this->load->view('about/contact.inc', '', true));
        // build the template
        parent::build_template();
    }
}


All included main content files are named the same as the function called in the controller. (index.inc , about_us.inc , contact.inc). Also, in the template_engine.php the site navigation is added (top and side) from a database.

Now for my dilemma... i've created a simple cms using ajax that allows me to update the content files (about_us.inc, contact.inc). But i also want to extend the ability to add pages using my cms system. My thoughts are to have a single controller that will allow me to build my pages based upon the link clicked (for example www.mydomain.com/about/about_us). That way i don't need a seperate about.php or misc.php controller file. I've tried hooks, routing and building MY_Controller but to no avail. Maybe i'm missing something very simple here....

There must be a way to access all my views without actually having a separate controller file for each subdirectory ?!? Any help would be greatly appreciated...

-Michael


  Check for One or More Valid Checkbox
Posted by: El Forum - 10-13-2007, 05:28 PM - No Replies

[eluser]RobbieL[/eluser]
Certainly are alot of Validation questions popping up. Thought I'd add to the pile. Smile

I've got a form that consists of a checkboxes only. They're all generated by a FOREACH loop. Each of them is going to have a unique name. Now, the user can't proceed without having atleast one of the checkboxes checked.

With CI's validation, I'm finding it impossible to get this done. Is it possible, or will I have to come up with my own validation function?


  Which MySQL Fields Should be Indexed?
Posted by: El Forum - 10-13-2007, 04:48 PM - No Replies

[eluser]Vik[/eluser]
I've got a database lookup that looks like this:

Code:
$this->db->where('id=', $user_id);
$this->db->join('Description', 'Description.NDB_No = user_prefs.NDB_No');
$this->db->join('ABBREV', 'Description.NDB_No = ABBREV.NDB_No');
$this->db->orderby('Long_Desc');
$main_database_query = $this->db->get('user_prefs');
I see I can have MySQL tables indexed on individual fields, and also, on combinations of fields.

I'm guessing that the user_prefs table should have an index for the combination of fields, $user_id and NDB_No - rather than individual indexes for each field. Is this correct?


  New learner/user...Need help on installation
Posted by: El Forum - 10-13-2007, 04:46 PM - No Replies

[eluser]forsooth[/eluser]
I've downloaded CI, but I have a perhaps dumb question. I want to use my local machine for the "server" -- localhost, I guess. I have WAMP installed.

The installation instructions give instructions for a remote server. Are there any available instructions (very explicit, very step-by-step) for a CI localhost scenario?

(Note: I registered as "phpdave" for the irony.)

Thanks,
phpDave


  Why do sessions handle http://domain.com different from http://www.domain.com?
Posted by: El Forum - 10-13-2007, 04:04 PM - No Replies

[eluser]dedavai[/eluser]
Does it have to do with CI or server configuration?


  Yet another yet another validation question
Posted by: El Forum - 10-13-2007, 02:20 PM - No Replies

[eluser]Unknown[/eluser]
Hi All,

I'm having some issues with the Validation class. It works correctly within one controller, but then when I pass to another controller, the same code does nothing, i.e., the run() method is returning true. I'm a newbie to CI, and not much better on PHP (I do mostly java).

Here's my index function in one controller:

Code:
$this->load->helper('html');
        $this->load->library('validation');

        $this->validation->set_error_delimiters('<div class="error">', '</div>');
        $rules['abstractTitle'] = "required";
        $rules['abstractText'] = "required";

        $this->validation->set_rules($rules);

        $fields['abstractTitle']    = 'Abstract Title';
        $fields['abstractText']    = 'Abstract Text';

        $this->validation->set_fields($fields);

        if ($this->validation->run() == FALSE)
        {

            $this->load->view('abstract/abstract_form_view');
        }
        else
        {
            $this->add();
        }

My abstract_form_view.php (partial)

Code:
<div>
    <label>Abstract Title: </label>
    &lt;?=$this->validation->abstractTitle_error; ?&gt;
    &lt;input type="text" name="abstractTitle" id="abstractTitle"
        value="&lt;?=$this-&gt;validation->abstractTitle; ?&gt;" maxlength="50" size="50" />
</div>
&lt;?php echo br(2); ?&gt;
<div>
    <label>Abstract Text:  </label>
    <p>(Paste or type in your abstract here - please, no more than 250 words.)</p>
    &lt;?=$this->validation->abstractText_error; ?&gt;
    &lt;textarea name="abstractText" id="abstractText"
        rows="25" cols="80" &gt;&lt;?php echo $this->validation->abstractText;?&gt;&lt;/textarea&gt;
</div>

When abstractText or abstractTitle are blank, the run() passes, and I get to the add().

I have the same code in another controller, and the validation works fine. I'm sure I'm missing something simple. I've read a few other related posts, and except for the multiple pages validation issue, they don't seem to be relevant. If the multiple pages issue is relevant, I'd appreciate any hints.

thanx
steve


  Use CI-based blog on not-CI project.
Posted by: El Forum - 10-13-2007, 01:00 PM - No Replies

[eluser]IzumeRoot[/eluser]
Hello Friends.
Who knows how I can use CI-based blog (forum, guest book and another) on not-CI project (cleanly php)? And another question. how can I use not-CI blog (and another) on CI-based project?


  CRUD - Rapyd vs CodeCrafter?
Posted by: El Forum - 10-13-2007, 08:41 AM - No Replies

[eluser]charlieD[/eluser]
Does anyone have any experience comparing these 2 CRUD packages or any other alternatives? (I found http://www.phpguru.org/static/TableEditor.html on another thread which seems like a possible candidate.)

I need them to create admin interfaces for my clients so ideally the output would be easy to customise (rename fields to human-friendly names, hide certain fields, customise with CSS).

Rapyd seems to have a nice visual style for clients and the tinyMCE inclusion looks good for creating a CMS.

Are these any good for replacing CMSs? I find that most CMS are bloated and focus on 'articles' (i.e. large blocks of HTML) rather than key/value pairs which is what I need on most real websites.


  Saving files to a database
Posted by: El Forum - 10-13-2007, 07:22 AM - No Replies

[eluser]bikuta[/eluser]
Hi guys,

I've been looking at the File uploading class in CI and it seems that it uploads the file to a folder on the server. What I'm looking for is a way to upload the file to the database instead of the file system.
Is there an example of how to go about doing this?


  problem with _POST array validation and repopulation, am i missing something or...?
Posted by: El Forum - 10-13-2007, 06:26 AM - No Replies

[eluser]smith[/eluser]
here is an example of my problem. it is attached, together with mysql test tables dumps.

http://rapidshare.com/files/62239050/test.rar.html

$this->validation->test_array is not visible to view when editing Sad
updated set_select is inside MY_Validation.php (updated set_select can work with _POST arrays)

form is populated when using insert (your_host/test_post/test_insert)
but form is NOT correctly populated when editing, even though all the variables exist inside a model

i am using print_r at the end of model script so that you can see that variables exist but inside view they are not visible. Please, if anyone wants to test, i will be very grateful...

Thank you

P.S. I was editing files from my existing project, so please excuse me for using too many view files...

and i am sorry for duplicating this post Sad


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Update from 4.6.0 to 4.6....
by FlavioSuar
Today, 04:17 AM
Setting baseURL in Regist...
by petewulf1
Today, 03:20 AM
Sessions old files are de...
by InsiteFX
Yesterday, 10:30 PM
Ajax post failing with Ty...
by PaulC
Yesterday, 12:23 AM
intermittent smtp failure...
by InsiteFX
05-11-2025, 11:30 PM
MVC vs MVCS vs CodeIgnite...
by FlavioSuar
05-10-2025, 10:33 AM
CodeIgniter Shield 1.0.0 ...
by timesprayer
05-10-2025, 05:22 AM
Website Traffic Drop Afte...
by InsiteFX
05-10-2025, 04:23 AM
Magic login link not work...
by InsiteFX
05-10-2025, 04:16 AM
Is codeigniter 5 upco...
by InsiteFX
05-10-2025, 04:10 AM

Forum Statistics
» Members: 145,825
» Latest member: vaanyasingh43
» Forum threads: 78,388
» Forum posts: 379,447

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB