Issue in blog

edited June 2015 in Modules
I am getting this error on the web page:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: blog_links
Filename: libraries/Fuel_blog.php
Line Number: 983

and then:

A Database Error Occurred
Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'published` = 'yes' ORDER BY `precedence` desc' at line 3

SELECT `fuel_blog_links`.* FROM (`fuel_blog_links`) WHERE `.`published` = 'yes' ORDER BY `precedence` desc

in the blog.php, there is this:

$config['tables']['blog_links'] = 'fuel_blog_links';

and in Fuel_blog.php:

function get_links($where = array(), $order_by = 'precedence desc', $limit = NULL, $offset = NULL, $return_method = NULL, $assoc_key = NULL)
{
$this->CI->load->module_model(BLOG_FOLDER, 'blog_links_model');
$this->CI->blog_links_model->readonly = TRUE;
$tables = $this->CI->config->item('tables');
$where[$tables['blog_links'].'.published'] = 'yes';
$links = $this->CI->blog_links_model->find_all($where, $order_by, $limit, $offset, $return_method, $assoc_key);
return $links;
}

I don't really see anything wrong that could be causing this error. Why would $tables['blog_links'] be an empty string?

Comments

  • edited 9:33AM
    Try downloading the develop branch which should fix that issue:
    https://github.com/daylightstudio/FUEL-CMS-Blog-Module
  • edited 9:33AM
    Am I doing this right?

    git.exe pull -v --progress "origin"

    From https://github.com/daylightstudio/FUEL-CMS-Blog-Module
    = [up to date] master -> origin/master
    = [up to date] develop -> origin/develop
    Already up-to-date.

    So I downloaded the zip, unzipped it, then did a comparison with what I have and there are no changes. :(
  • edited 9:33AM
    If you are using Git and pull, you'll then need to switch from the master to the develop branch (my guess is that you are on master and not the develop branch).

    If you download the zip, be sure to do it from the develop branch URL:
    https://github.com/daylightstudio/FUEL-CMS-Blog-Module/tree/develop
  • edited 9:33AM
    This still gets a problem:

    A Database Error Occurred

    Error Number: 1066

    Not unique table/alias: 'fuel_blog_users'

    SELECT COUNT(*) AS `numrows` FROM (`fuel_blog_posts`) LEFT JOIN `fuel_blog_users` ON `fuel_blog_users`.`id` = `fuel_blog_posts`.`author_id` LEFT JOIN `fuel_blog_users` ON `fuel_blog_users`.`fuel_user_id` = `fuel_users`.`id`

    The problem is the last LEFT JOIN table should be fuel_users, not fuel_blog_users.
  • edited 9:33AM
    At least I think it should be. If I make the change, then clicking on the navigation "Posts" just gives me a continual spinner.
  • edited 9:33AM
    Also, if I try to create a post, I get this error:

    A Database Error Occurred

    Error Number: 1054

    Unknown column 'fuel_tags.context' in 'where clause'

    SELECT fuel_tags.id, fuel_tags.name FROM (`fuel_tags`) LEFT JOIN `fuel_categories` ON `fuel_categories`.`id` = `fuel_tags`.`category_id` WHERE (FIND_IN_SET("blog", fuel_tags.context) OR fuel_tags.context="") ORDER BY `fuel_tags`.`name` asc

    There is no fuel_tags.context. Was this meant to be fuel_categories.context?
  • edited 9:33AM
    Changing the last line here worked for the fix to creating a post:

    blog_posts_model.php:
    function __construct()
    {
    parent::__construct('blog_posts', BLOG_FOLDER); // table name
    $CI =& get_instance();

    if ($CI->fuel->blog->config('multiple_authors'))
    {
    $authors = array('authors' => array('model' => array(BLOG_FOLDER => 'blog_users')));
    $this->has_many = array_merge($authors, $this->has_many);
    }
    $this->has_many['tags']['where'] = '(FIND_IN_SET("blog", '.$this->_tables['fuel_categories'].'.context) OR '.$this->_tables['fuel_categories'].'.context="")';
  • edited 9:33AM
    You'll need to run the sql update in the install folder
  • edited 9:33AM
    I did. That didn't fix the issues where I needed to make the code changes because it referenced the incorrect table.
  • edited 9:33AM
    Sorry... that particular SQL error is because you aren't on the latest version of FUEL I'm assuming. the fuel_tags.context field is in the latest version of FUEL.
  • edited 9:33AM
    I've got the blog working again. Thanks!

    Question though: When you create an Author, then go back to edit that user, you can change it to a different Fuel user (it changes the fuel_user_id). But, the Display Name stays the same as the first User. Is there a way of resolving this so that the display_name changes each time the fuel_user_id is changed?
  • edited 9:33AM
    The display_name isn't specifically tied to anything but that fuel_blog_users.display_name so I'm not sure what you would want to change it to.
  • edited 9:33AM
    It's just confusing to the end user to have someone else's name displayed when they change the user based on the fuel user id.
  • edited 9:33AM
    FYI, because you convinced me to use the developer branch, it looks like your fuel_1.4_schema_changes.sql is missing some updates to the fuel_tags tables.

    Specifically:

    `description` text COLLATE utf8_unicode_ci NOT NULL,
    `context` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
    `language` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'english',

    I had to add these in manually.
  • edited June 2015
    This one too, in fuel_categories:

    `description` text NOT NULL,
    `language` varchar(30) NOT NULL DEFAULT 'english',
  • edited 9:33AM
    I also made these further modifications:

    ALTER TABLE `fuel_categories`
    CHANGE COLUMN `name` `name` VARCHAR(255) NOT NULL DEFAULT '' COLLATE 'utf8_unicode_ci' AFTER `id`,
    CHANGE COLUMN `slug` `slug` VARCHAR(255) NOT NULL DEFAULT '' COLLATE 'utf8_unicode_ci' AFTER `name`,
    CHANGE COLUMN `description` `description` TEXT NOT NULL COLLATE 'utf8_unicode_ci' AFTER `slug`,
    CHANGE COLUMN `context` `context` VARCHAR(100) NOT NULL DEFAULT '' AFTER `description`,
    CHANGE COLUMN `language` `language` VARCHAR(30) NOT NULL DEFAULT 'english' COLLATE 'utf8_unicode_ci' AFTER `context`;
  • edited 9:33AM
    One other issue in Blogs I haven't been able to track down yet is when you edit a blog and go to the Associations tab, the Category drop down only contains the first category from the fuel_categories, although you may have more than one.
  • edited 9:33AM
    There is a fuel_1.3_schema_changes.sql file you can run with those SQL changes in it (the 1.4 schema is for the next release and 1.3 is the current master).

    For the fuel_categories, the blog_posts module is setup to pull in categories that have the context value of blank or "blog". It has the following where condition tied to it:
    (context = "blog" OR context = "") AND language = "{language}" OR language = ""
Sign In or Register to comment.