_common_query() interferes with Search module

edited January 2016 in Modules
Hi (again) --

I want the preview path for my news articles to include info from the fuel_categories table, so I made this modification to _common_query() in news_module.php:

function _common_query($display_unpublished_if_logged_in = TRUE){ parent::_common_query(TRUE); if(!empty(uri_segment(4))){ $this->db->select('n.id, n.category_id, fc.slug as category_slug'); $this->db->from('news as n, fuel_categories as fc'); $this->db->where('n.id ='.uri_segment(4)); } }

This works! The preview paths are showing up as /news/category-slug/news-slug like I want.

But now when I try to reindex with the Search module (from Github), I get an error:
A Database Error Occurred Error Number: 1054 Unknown column 'reindex' in 'where clause' SELECT news.*, fuel_categories.slug as category_slug, fuel_categories.id as category_id, YEAR(news.publish_date) as year, DATE_FORMAT(news.publish_date, "%m") as month, DATE_FORMAT(news.publish_date, "%d") as day, `n`.`id`, `n`.`category_id`, `fc`.`slug` as category_slug FROM (`news` as n, `fuel_categories` as fc, `news`) LEFT JOIN `fuel_categories` ON `fuel_categories`.`id` = `news`.`category_id` LEFT JOIN `fuel_relationships` ON `fuel_relationships`.`candidate_key` = `news`.`id` AND fuel_relationships.candidate_table = "news" AND fuel_relationships.foreign_table = "fuel_tags" LEFT JOIN `fuel_tags` ON `fuel_tags`.`id` = `fuel_relationships`.`foreign_key` WHERE `n`.`id` =reindex GROUP BY `news`.`id` ORDER BY `publish_date` desc Filename: C:\wamp\www\zdlaw_fuel\fuel\codeigniter\database\DB_driver.php Line Number: 331

Any idea how I can stop this? Perhaps it has something to do with this line in Search.php?

$config['search']['index_modules'] = TRUE;

If so, I have no idea what to do. I tried to do _common_joins() instead of _common_query(), but that didn't work.

Thanks in advance!!

Comments

  • edited 1:20PM
    ACTUALLY, I just reread my post and I know what the issue is, it's the fact that I used uri_segment(4) to get the news article's ID. I'm going to see if I can figure out how to pass the ID a different way (any tips are, of course, appreciated ;).
  • edited 1:20PM
    I believe their is a $_POST['id'] value you can access as well.
  • edited January 2016
    It worked! Thanks so much for all of your help! Fuel is so powerful, the learning curve for me is just a little steep!
Sign In or Register to comment.