Welcome Guest, Not a member yet? Register   Sign In
  good pay template site?
Posted by: El Forum - 11-12-2008, 05:27 PM - Replies (6)

[eluser]edwardmolasses[/eluser]
hi everyone,

I'm developing a site that needs multiple templates and was just wondering if anyone had any recommendations for sites that offer templates to purchase?

I looked some up and found a bunch that use only tables :bug: or they are too small. I need some where the css is pretty flexible and stable.

thanks!

andrew.


  Problem with file upload on edit page
Posted by: El Forum - 11-12-2008, 04:40 PM - Replies (4)

[eluser]opel[/eluser]
I have been working on a cms for a small site and having a problem with the edit page and file upload.

My edit page shows the currently uploaded file and option to upload a new file. THe problem occurs if I submit an edit page without a putting a new file in the "file" field as it tried to do the upload in the model even though I have put if not null. My code is below, could anyone advise where I am going wrong please ?

THanks

Code:
function update()
    {    
    

    
      $content = array('title' => $_POST['title'],
                      'category' => $_POST['category'],
                    'description' => $_POST['description'],
                  'order' => $_POST['order']);
    
    if ($_FILES['myfile'] != NULL)
    {
        $config['upload_path'] = './includes/uploads/';
        $config['allowed_types'] = 'gif|jpg';
        $config['max_size'] = '1000';
        $config['remove_spaces'] = true;
        $config['overwrite'] = true;
        //$config['max_width']  = '400';
        //$config['max_height']  = '400';
        $this->load->library('upload', $config);    
        
        if( ! $this->upload->do_upload('myfile'))
        {
            echo $this->upload->display_errors();
            exit();
        } else
        {
        
            // Thumbnail
            $data = array('upload_data' => $this->upload->data());
          $temp=$this->upload->data();
          
          $thumb['image_library'] = 'GD2';
          $thumb['source_image'] = './includes/uploads/'.$temp['file_name'];
          $thumb['new_image'] = './includes/uploads/thumb/'.$temp['file_name'];
          $thumb['maintain_ratio'] = TRUE;
          $thumb['create_thumb'] = TRUE;
          $thumb['quality'] = '100';
          $thumb['height'] = '80';
          $thumb['width'] = '80';
      
          $this->load->library('image_lib', $thumb);
          $this->image_lib->resize();
          
           //making a thumbnail
            $this->image_lib->clear();
            
            //insert to the DB


            $content['file'] = $temp['file_name'];


        }

        $this->db->where('id', $_POST['id']);
        $this->db->update($this->table, $content);
      }


    }


  Pagination: or Why does AR class reset the query?
Posted by: El Forum - 11-12-2008, 04:15 PM - Replies (2)

[eluser]steward[/eluser]
Suppose I build a complex SQL SELECT from a search form.

I will need to call db->count_all_results() so I have that value for pagination.
I will also need to get the results db->get().

Using either of these methods resets the query. So it must be constructed again.

Okay, I'll create a function to build the query:

Code:
constructQuery($args); // set up joins, selects, conditions etc
  $data['count'] = $db->count_all_records();
  constructQuery($args);
  $data['query'] = $db->get();

Seems to me the database might have an option NOT to reset the query after a count.
Or. I am way out in left field. Maybe I should not be using the AR class.
Which kinda makes sense, as there is no "active" record, this is a search/browse.

The context of this question is pagination. I am porting from a different system which sent the query directly into the pagination system as a last step. The queries (count and get) actually took place in the pagination class.

The pagination I wish to use is different from CI as it provides more info, and allows the user to enter a page number (jump to page). That may simply be my issue.

Noob here. Any comments?


  Am i coding the/a right way ?
Posted by: El Forum - 11-12-2008, 04:08 PM - No Replies

[eluser]___seb[/eluser]
Hi,

because i'm not familiar with CI (neither any framework, MVC and object style), I don't know if i code the right way.
Here is the i made to test CI. Note that the templates caching (smarty) is not yet used.

this code uses datamapper.
What does it do :
- display bookmarks related to tag in the url (requested)
+ a list of subtags (tags associated with the found links) (less bookmarks)
+ links to the bookmarks, each without one of the found tags. (more bookmarks)
model : nothing special

Code:
class Bookmark extends DataMapper
{
    var $has_many = array('tag');

    function Bookmark()
    {
        parent::DataMapper();
    }

}

Controler : (file attached)
Code:
define('SEPARATEUR','~');
define('ITEMS_PER_PAGE',10);

class Bookmark_ctrl extends Controller
{

    /**
    * Constructor
    */
    function Bookmark_ctrl() // constructeur : appellé a chaque fois
    {
        parent::Controller();
        $this->load->model('Bookmark');
        $this->load->model('Tag');
        $this->load->library('smarty_ci');
    }
    
    /**
    * Actions
    */
    function index($tags_inline = false, $page = 1) // appellé si pas d'action de définie
    {
        $CI =& get_instance();
        $base_url = dirname($CI->config->system_url()).'/';

        $requested_tags_array = array();        // array of tags requested in url     [string]
        $requested_tags_found_array = array();    // array of tags requested in url that exist in db  [id => int] [tag => string]
        $requested_tags_found_array_flat = array();    // array of tags requested in url that exist in db  [id => int] [tag => string]
        $requested_tags_with_links = array();
        $requested_tags_not_found_array = array();    // array of tags requested in url that do not exist in db     [string]
        $requested_tags_found_str = '';        // string of requested tags'id     | ('1,6,9...')

        $requested_tags_array = $this->_get_request_tags(&$tags_inline);
        $this->_filter_requested_tags(    $requested_tags_array,
                        &$requested_tags_found_array,
                        &$requested_tags_not_found_array,
                        &$requested_tags_found_array_flat);
        unset($requested_tags_array, $inline);
        

        $bookmark = new bookmark();
        $bookmarks = array();
        $bookmarks_out = array();


        // --- the bookmarks ---

        if(empty($requested_tags_found_array)) // no requested tags found
        {
            $bookmarks = $bookmark->limit(ITEMS_PER_PAGE)->get()->all;
        }
        else
        {
            $bookmarks_ids_array = $this->_get_booksmarks_ids_by_tags($requested_tags_found_array);
            $bookmarks = $bookmark->where_in('id',$bookmarks_ids_array)->get()->all;
        }
        // out as array
        $bookmark_fields = $this->db->list_fields('bookmarks');
        foreach($bookmarks as $bookmark_obj)
        {
            $array = array();
            foreach($bookmark_obj as $k => $v)
            {
                if(in_array($k, $bookmark_fields))
                    $array[$k] = $v; //array
            }
            // add its tags
            $tags = $bookmark_obj->tag->get()->all;
            $tags_out = array();
// ---------------
            foreach($tags as $tag_obj)
            {
                $tags_out[] = array('id' => $tag_obj->id , 'tag' => $tag_obj->tag, 'url' => $this->make_link_refine( $tag_obj->tag , $requested_tags_found_array_flat) );
            }
            $array['tags'] = $tags_out;
// ---------------
            $bookmarks_out[] = $array; //array('id' => $bookmark_obj->id , 'url' => $bookmark_obj->url  );
        }


        // --- (bookmarks) related tags ---

        $tag = new tag();
        $tags = array();
        $tags_out = array();

        
        if(empty($requested_tags_found_array))
        {
            $tags = $tag->get()->all;
        }
        else
        {
            $tags_ids_array = $this->_get_tags_ids_by_bookmarks($bookmarks_ids_array);
            $tags = $tag->where_in('id',$tags_ids_array)->get()->all;
        }

        // add url to tags
        $tags_out = array();
        foreach($tags as $tag_obj)
        {
            $tags_out[] = array('id' => $tag_obj->id , 'tag' => $tag_obj->tag, 'url' => $this->make_link_refine( $tag_obj->tag , $requested_tags_found_array_flat) );
        }

        // --- requested tags with link to remove them ---
        foreach($requested_tags_found_array_flat as $tag)
            $requested_tags_with_links[] = array('tag' => $tag, 'url' => $this->make_link_enlarge( $tag , $requested_tags_found_array_flat) );

        $this->smarty_ci->assign('tags',$tags_out);
        $this->smarty_ci->assign('bookmarks',$bookmarks_out);
        $this->smarty_ci->assign('requested_tags',$requested_tags_with_links);

        $this->smarty_ci->display('base.tpl');
        $this->output->enable_profiler(TRUE);

    }

    /**
    * privates functions
    */

    /**
    * array of requested tags (requested by url)
    * @param string tags in url ( 'tag1SEPARATEURtag2SEPARATEURtag3' => tag1~tag2~tag3 )
    * @return array ( 'tag1', 'tag2', ... )
    * @version 0.1
    */
    private function _get_request_tags(&$tags_inline)
    {
        $tags_inline = trim ( $tags_inline, SEPARATEUR );
        $requested_tags_array = explode(SEPARATEUR ,$tags_inline);
        return array_unique($requested_tags_array);
    }

// other functions removed because of message size limit, files attached
}


  forc_download() at a wite space at the begining of file content
Posted by: El Forum - 11-12-2008, 04:05 PM - No Replies

[eluser]Amir Bukhari[/eluser]

Code:
$file = $media->filepath;
$data = file_get_contents(SITE_BASE.$file);
            
force_download("media_file_$id.rm", $data);

the file got download correctly and it is a RM file.

but real player can not open it. then i figured there is a white space at the begining of the file, which is not part of the content. after removing the that white space realplayer can play the file.

if any of PHP file include a white space then header() function should complain about it.

any help?


  HMVC vs MVC
Posted by: El Forum - 11-12-2008, 03:02 PM - No Replies

[eluser]al404[/eluser]
i'm new at CI and at MVC, but while i was reading trying to figure out my default best dir structure: a structure that will let me easyly re-use some part of my web site for next projects

i found out HMVC, but is not clear to me if is usefull only for very big project, mine could be between 20 and 30 standard PHP pages, but some times can growe... of course never now in advance :-D

so i was wondering is HMVC is usefull for me?


  [NEWBIE] Stylesheet - It's ok?
Posted by: El Forum - 11-12-2008, 01:57 PM - Replies (1)

[eluser]walrus_lt[/eluser]
Hello, i am newbie in ci, and i want to check my self, are i am doing good.
Are i am doing good? / Or, are it could be better than this -> http://img296.imageshack.us/my.php?image=sometl3.jpg


  Meta Helper!
Posted by: El Forum - 11-12-2008, 01:37 PM - No Replies

[eluser]Iverson[/eluser]
I liked how Digg pulled info from external sites so I figured I'd make a helper to do it. Simply call the function "meta_info()" and if you provided a valid URL, it will spit back an array with all the meta tags applicable to that site. Since the html helper already has a meta function, I threw it in with the html helper. If successful, the function returns an array including the following indexes:

url: the given url
title: the title of the site
tags: an array with all the meta tags on the site


Test it out!
http://www.gandylabs.com/ci.php/html_helper

Download it!
http://www.gandylabs.com/html-helper


  Bug // Improvement on DB_cache
Posted by: El Forum - 11-12-2008, 01:16 PM - No Replies

[eluser]Unknown[/eluser]
Hi all,

I just notice that the sql command 'SHOW' isn't an allowed command in the cache.
I added it on the line 265 of DB_Cache.php. It could be usefull to cache this kind of command.
By the way, thanks a lot for CI, it's amazing !

Mark


  HMVC extension help
Posted by: El Forum - 11-12-2008, 11:56 AM - Replies (7)

[eluser]new developer[/eluser]
I have made a little application with pages and user management. But its becoming quite cluttered so i thought i will give a go to HMVC extension. I read about HMVC. I have downloaded the .zip. Extracted it but did not work. Information says I should have some libraries and helper function. But i extracted i got only three files as under.

My_router.php
Modules.php
Controller.php

I placed them in the /application/library/ and created a module called test with its controller and views. but did not work. Are there any helper classes required.If anyone can please tell me the detailed information. How to go on about this ? I will really appreciate your help.


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

Username
  

Password
  





Latest Threads
Type error in SYSTEMPATH\...
by kenjis
11 minutes ago
codeigniter4/queue Not lo...
by mywebmanavgat
21 minutes ago
Depractaion request warni...
by kenjis
23 minutes ago
Random 403 in Checkout wi...
by ozornick
4 hours ago
Version number stays un-u...
by trunky
10 hours ago
Array to HTML "Table"
by HarmW94
Yesterday, 11:04 AM
shortcodes for ci4
by xsPurX
Yesterday, 09:29 AM
TypeError when trying to ...
by b126
Yesterday, 12:04 AM
Webhooks and WebSockets
by InsiteFX
04-18-2024, 10:39 AM
Retaining search variable...
by pchriley
04-18-2024, 05:46 AM

Forum Statistics
» Members: 84,643
» Latest member: toto12platform
» Forum threads: 77,564
» Forum posts: 375,911

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB