Welcome Guest, Not a member yet? Register   Sign In
  implementing a search engine
Posted by: El Forum - 06-29-2007, 07:32 AM - No Replies

[eluser]andyd[/eluser]
Hi all CIers, i have been Rapidly developing a website for a UK store and wanted to find out if there was anyone with a 'off the shelf' search engine script.

I want to search multiple tables for a query of words and wondered if anyone can point me in the right direction.

Kind regards

Andy


  auto_typography()
Posted by: El Forum - 06-29-2007, 04:11 AM - No Replies

[eluser]Crimp[/eluser]
Use of the </p><p> for pre-defined block-level elements with tags.

Example to generate headings in flowing text:

Code:
<strong>Hole</strong>
You may find yourself in the hole doing this.

Output heading:
Code:
</p><strong>Hole</strong><p>

The "ol" in Hole makes it an ordered list.

Code:
// Block level elements that should not be wrapped inside <p> tags
var $block_elements = 'div|blockquote|pre|code|h\d|script|ol|un';


  Dealing with tabbed interface and validation of multiple forms
Posted by: El Forum - 06-29-2007, 02:17 AM - No Replies

[eluser]Unknown[/eluser]
Hi everyone,

I'm working with CI on a project which implies a tabbed interface.

The contents of all the tabs will be rendered in the same view file which will be handled by a controller so that there will be no page load when the user will click on the tabs. The tab system will be done in Javascript.

Now I got a problem, let me show you my code.
The view file back_configuration_view.php looks like this :

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;title&gt;My Website - Item 1 page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    <h1>Menu Items</h1>
    <ul>
        <li>&lt;?=anchor('back_page1', 'Item 1');?&gt;</li>
        <li>&lt;?=anchor('back_page2', 'Item 2');?&gt;</li>
    </ul>
    
    &lt;!--Tab 1--&gt;
    <div>
        <h2>Tab 1</h2>
        &lt;?=$feedback_tab4?&gt;
        &lt;form name="conditions" action="&lt;?=base_url().'back_configuration/index/cgv'?&gt;" method="post"&gt;
            &lt;?=$this->validation->cgv_error; ?&gt;
            <p>&lt;textarea name="cgv"&gt;&lt;?=$cgv?&gt;&lt;/textarea&gt;</p>
            <p>&lt;input type="submit" value="Save" /&gt;</p>
        &lt;/form&gt;
    </div>
    
    &lt;!--Tab 2--&gt;
    <div>
        <h2>Tab 2</h2>
        &lt;form name="form_tab2" action="&lt;?=base_url().'back_configuration/index/adresses_email'?&gt;" method="post"&gt;
            &lt;?=$this->validation->email_admin_error; ?&gt;
            <p><label>Admin email address</label>&lt;input type="text" name="email_admin" value="&lt;?=$email_admin?&gt;" /&gt;</p>
            &lt;?=$this->validation->email_notifications_error; ?&gt;
            <p><label>Contact email address</label>&lt;input type="text" name="email_contact" value="&lt;?=$email_contact?&gt;" /&gt;</p>
            <p>&lt;input type="submit" value="Save" /&gt;</p>
        &lt;/form&gt;
    </div>
&lt;/body&gt;
&lt;/html&gt;

As you can see, I got 2 tabs on the same page, each tab includes a form.
Now lets see the controller back_configuration.php :

Code:
&lt;?php
class Back_configuration extends Controller {
    function Back_configuration() {
        parent :: Controller();
        $this->load->helper('url');
        $this->load->helper('form');
        $this->load->library('validation', '', TRUE);//Loads Validation Library
        $this->load->model('Dbbackset', '', TRUE);
        $this->load->model('Dbbackget', '', TRUE);
    }
    function index() {
        $data['feedback_tab1']= $this->_adresses_email();
        $data['feedback_tab2']= $this->_cgv();
        //Get the datas to edit
        $emails = $this->Dbbackget->getEmails();
        $data['email_admin'] = $emails['email_admin'];
        $data['email_contact'] =$emails['email_contact'];
        $data['cgv'] = $this->Dbbackget->getCGV();
        $this->load->view('back_configuration_view', $data);
    }
    function _adresses_email() {
        $renvoi= "";
        $this->validation->email_admin_error= "";
        $this->validation->email_contact_error= "";
        $rules['email_admin']= "required|valid_email";
        $rules['email_contact']= "required|valid_email";
        $this->validation->set_rules($rules);
        //Repopulating the form
        $fields['email_admin']= 'email_admin';
        $fields['email_contact']= 'email_contact';
        $this->validation->set_fields($fields);
        if ($this->validation->run() == TRUE) {
            $tab_emails= array (
                'email_admin' => $_POST['email_admin'],
                'email_contact' => $_POST['email_contact']
            );
            $update= $this->Dbbackset->edit_email($tab_emails);
            if ($update == 1) {
                $renvoi= "Update done.";
            }
            else {
                $renvoi= "Update error.";
            }
        }
function _cgv() {
        $renvoi= "";
        $this->validation->cgv_error= "";
        $rules['cgv']= "required";
        $this->validation->set_rules($rules);
        //Repopulating the form
        $fields['cgv']= 'cgv';
        $this->validation->set_fields($fields);
        if ($this->validation->run() == TRUE) {
            $update= $this->Dbbackset->edit_cgv($_POST['cgv']);
            if ($update == 1) {
                $renvoi= "Update done.";
            }
            else {
                $renvoi= "Update error.";
            }
        }
        return $renvoi;
    }
?&gt;

As you can see, the only public function of my controller is index(). index() loads the two private functions _adresses_email() and _cgv(). Each of these two functions should handle one of the two form "displayed" on my view. The problem I got is that Validation works fine for the first form but silently fails.

I understand why this is happening : Validation is loaded for the entire controller and in fact I use the same instance of the Validation library to handle both forms. So when I try to validate the second form, required fields of the first form are missing, preventing the validation to work properly.

Here's the question : is there a mean to instanciate more than one validation library in my case?

I've tried to do something like that :
Code:
$tab1= & get_instance();
$tab1->load->library('validation', '', TRUE)
And then calling $tab1->validation ... instead of $this->validation. It doesn't work at all.

Maybe what I want to do is impossible the way I want it to be done Smile In that case, what is the cleanest way to make that stuff working fine?

Any help or piece of advice will be really appreciated. Thanks in advance.


  pagination and form
Posted by: El Forum - 06-29-2007, 12:33 AM - No Replies

[eluser]deineMudder[/eluser]
Hello everyone.
is there any chance of keeping submitted form values when i use the pagination?
simple idea:

i got a search form. when submitting the form i use the validation class to refill the form with the necessary values and use those values to create my search query. i get my pagination displayed and everything works fine for the first page. if i use my pagination and click another site, my form is empty again and i get no results for the query any longer.

i bet it is a general thinking problem.
maybe anyone can come with a solution or suggestion.

thank you


  Multiple Sites - minor questions
Posted by: El Forum - 06-29-2007, 12:20 AM - No Replies

[eluser]Gordaen[/eluser]
After reading quite a bit about CI, I've decided to give it a try. I'm halfway through redesigning a site, so I figured now is a good time to make the changes. I have a few questions before I get too far though.

I read a few past posts about running multiple sites/applications through CI, and I think I have decided to do mine this way:

/ci_path/application/sitename-dev/
/ci_path/application/sitename-live/

Obviously there will be quite a bit of overlap between the two, but it feels "safer" to keep the development site as a separate application. That way I can be as experimental as I want without too much worry. If everything is good on the dev site, I can copy over the appropriate libraries, views, etc. The naming convention should also make it clear/easy if I decide to modify more of my sites to use CI. Does that make sense?

Would it be best to create additional separate paths for logs, cache, etc. in order to help keep the sites separate? e.g., $config['log_path'] = '/ci_path/logs/sitename-dev/';

Is there any logical way of tying subversion in with all of this? Right now, the site is in a svn repository. I work on the dev site until everything is good and check in the changes. Then I just do an "svn up" on the live site. The way I have it now, however, is that a "settings.php" file is loaded that configures various settings (e.g., logging, database info, etc.). With CI, it makes more sense to just have the appropriate info in each "site's" config file, which would mean I obviously would not include that in the svn repository (unless I used svn hooks, but that's getting away from the simplicity I am going for). Does it make sense to use svn and just be very selective about which files are in the repository, or would it be better to have an auto-loaded config file, or some other option? I don't have to use subversion, I just find it extremely useful.

That's it for now. Thanks for reading such a long (and possibly rambling) first post Smile


  CI pagination links problem
Posted by: El Forum - 06-29-2007, 12:07 AM - No Replies

[eluser]Kryptonian[/eluser]
Hello guys

Have you guys encountered this in Code Igniter pagination for example you have a list of records then if you clicked the pagination link like number 2 you will go the second page but if you check the pagination links.... the page number 2 is not in bold format. The bold format is still in the 1st page (number 1).



Here's the code:
Code:

&lt;?php

// ------------------------------- my controller --------------------------------- //
function index($page = '0') {

$pagination_config['base_url'] = site_url() . 'settings/categories/index/';
$pagination_config['total_rows'] = $total;
$pagination_config['per_page'] = '5';
$pagination_config['full_tag_open'] = '<p>';
$pagination_config['full_tag_close'] = '</p>';
$this->pagination->initialize( $pagination_config );

echo $this->pagination->create_links();

}

// ------------------------------- my model --------------------------------- //
function __construct($page = 0) {
// call parent constructor
parent::Model();

$CI =& get_instance();
$CI->load->model( 'Database_model' );

$user_code = $this->session->userdata( 'user_code' );
$company_code = $this->session->userdata( 'company_code' );

$today = date("Y-m-d");
$tomorrow = date('Y-m-d', strtotime("+1 day, $today"));

$where =
"
`company_code` = '$company_code'
AND '$tomorrow' BETWEEN `valid_from` AND `valid_to`
";

$order_by = ' ORDER BY `category_id` ASC LIMIT '.$page.', 5';
$result = $CI->Database_model->select( 'DISTINCT *', CATEGORY, $where, $total, $order_by );

return $result;
}


?&gt;


Thanks in advance ;-)


  Documentation Error
Posted by: El Forum - 06-28-2007, 06:20 PM - No Replies

[eluser]DennisP[/eluser]
On this page, there is an error.

In the example model, the following is found:

Code:
class Blogmodel extends Model {

    var $title   = '';
    var $content = '';
    var $date    = '';

However, later on, the naming convention is different.

Code:
class User_model extends Model {

    function User_model()
    {
        parent::Model();
    }
}

Am I missing something, or was there a typo? It's entirely possible I'm screwed up. I'm a n00b to CodeIgniter.


  Best practices - integrating other code into CI
Posted by: El Forum - 06-28-2007, 05:59 PM - No Replies

[eluser]Myles Wakeham[/eluser]
I have a large framework of code that I've built up over the past year or so with CI and its great. However its not AJAX enabled, and along comes a really great tool that I want to use (Delphi for PHP) that implements a really nice WYSIWYG IDE for code generation, and is based on the Qooxdoo AJAX framework.

So I have started to try and integrate the code that it creates into my CI framework. The code that it builds is a PHP file with typically a class per form, a series of require_once lines for included code, and an associated XML file that contains all the properties of the class that are used for display.

The HTML that it sends to the browser has a bunch of included Javascript libraries for the AJAX stuff, but this is typically generated and sent through the PHP code that it creates.

I've tried to work out how best to integrate this sort of code. Its not a CI library, nor is it a plug-in. I use Smarty a lot and I'd like to integrate these pages as 'blocks' of HTML within my existing page templates, but that doesn't work very well because of all the Javascript header content. So I moved all of their JS files into my template header (which worked ok) and now I'm left with the resulting code to integrate.

If anyone has had experience in trying to integrate code produced by other 3rd party code generators, etc. into CI and has some suggestions on things they did that worked well, I'm all ears.

Thanks
Myles


  Questions about PayPal Library
Posted by: El Forum - 06-28-2007, 05:18 PM - No Replies

[eluser]CI Lee[/eluser]
Hello all,

I have integrated the paypal module into a site and it I have it working with the exception of a few things. Mainly it is passing the same data to the paypal form and I have no way to uniquely identify the payment with an order. So I wanted to pass some data to through the custom field.

Code:
$this->paypal_lib->add_field('custom', '1234567890'); // <-- Verify return

I was wondering if anyone had any ideas or examples of how to use this to generate unique data? I was thinking I would md5 the date of the form submission, enter that into the db and then pass that here to use as the custom data... but I could not get it to work.

Thanks for any and all help you can provide.

Lee


  question about views and a main layout file
Posted by: El Forum - 06-28-2007, 03:54 PM - No Replies

[eluser]jvittetoe[/eluser]
i am trying to create a simple app that will basically have the same basic layout from page to page. how can i got about creating a main layout file like this...

Code:
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;

<h1>Hi</h1>
<ul id="nav">
<li>link</li>
<li>link</li>
<li>link</li>
</ul>


<div id="mainContent">
//i want to load each view here
// basically i want to load the main layout file each time with a different view
// here depending on which page they go to. ie; login, register, profile, yada yada...

</div>


<ul id="footer">
<li>link</li>
<li>link</li>
<li>link</li>
</ul>



&lt;/body&gt;
&lt;/html&gt;

and just swapping the views from inside the #mainContent.

an example login view that i want loaded inside of #mainContent
Code:
<h2>Login Here</h2>
&lt;form&gt;
...
&lt;/form&gt;


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

Username
  

Password
  





Latest Threads
Insert in joint table bef...
by kcs
52 minutes ago
How to Find & Hire Codeig...
by php_rocs
1 hour ago
CI NEEDS A PROPER DOCUMEN...
by ALTITUDE_DEV
1 hour ago
Optimize.php make a probl...
by ALTITUDE_DEV
1 hour ago
6 hard truths about learn...
by php_rocs
1 hour ago
I built 30 startups in 20...
by php_rocs
1 hour ago
4.4.1 to 4.4.8 base_url p...
by xsPurX
1 hour ago
CodeIgniter v4.5.0 Releas...
by LP_bnss
2 hours ago
Gateway time out CI 4.4.1
by kenjis
4 hours ago
Need PHP Developer
by Sid.M
8 hours ago

Forum Statistics
» Members: 86,987
» Latest member: 8daycomtop
» Forum threads: 77,629
» Forum posts: 376,281

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB