开发者

CodeIgniter controller not interpreting hyphen correctly in function call

I'm having an odd problem. My controller is trying to call uri segments and is not interpreting the hyphen correctly. I don't get any error. Just the rest of the page beyond the call doesn't render. This is for a CMS and I have created an edit_market function in my markets controller. I want to be able to call the page content for a page, which is referenced in the database by the page navigation name, which is sometimes hyphenated (consumer-goods, for example).

Here is my controller:

function edit_market($page=NULL) {

// Send c开发者_如何转开发opy and images to page
$data['query'] = $this->markets_materials_model->get_content('markets', $page);

... load view ...

My markets_materials_model:

function get_content($table, $category) {
    $this->db->where('navigation', $category);
    return $this->db->get($table)->result();    
} 

This works fine for all links that don't have a hyphen, but fails when the link has a hyphen. What is causing this? The only way I can edit these pages right now is by using edit_market in my URI rather than being able to create a route that has "edit-market" in it. I believe if I remember right that accessing controllers directly was a bad practice.


There is absolutely nothing wrong with using the controller name: not sure where it came about that it is a bad practice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜