1 (edited by downliner 2008-12-06 18:06)

Topic: Using extensions to replace core code?

I'm needing to edit a query on index.php but don't understand how I add my additional code into the query? I believe this is possible so if someone can explain how it works I'll figure the rest out for myself smile

Additional code I need to add is highlighted red.

($hook = get_hook('in_main_output_start')) ? eval($hook) : null;

// Print the categories and forums
$query = array(
    'SELECT'    => 'c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster',
    'FROM'        => 'categories AS c',
    'JOINS'        => array(
        array(
            'INNER JOIN'    => 'forums AS f',
            'ON'            => 'c.id=f.cat_id'
        ),
        array(
            'LEFT JOIN'        => 'forum_perms AS fp',
            'ON'            => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
        )
    ),
    'WHERE'        => ''.$more_sql.' AND (fp.read_forum IS NULL OR fp.read_forum=1)',
    'ORDER BY'    => 'c.disp_position, c.id, f.disp_position'
);

($hook = get_hook('in_qr_get_cats_and_forums')) ? eval($hook) : null;

When I use this edited code in index.php it works as intended, I'm just unsure about how to replace the original core query with my edited version using manifest.xml?

Re: Using extensions to replace core code?

Place in the 'in_qr_get_cats_and_forums' hook something like this:

$query['WHERE'] = $more_sql.' AND ('.$query['WHERE'].')';

Re: Using extensions to replace core code?

Many thanks, I understand how it works now big_smile

Re: Using extensions to replace core code?

It's just like a simple array. Replace what you want to replace. smile

5 (edited by downliner 2008-12-07 15:16)

Re: Using extensions to replace core code?

I'm still not getting it it seems. I've only just learnt the basics of PHP and finding the jump from modding 1.2 to 1.3 more difficult than I originally thought it would be. These hooks give me a headache sad

In the above example of:

$query = array(
    'SELECT'    => 'c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster',

is it possible to add into the select, eg:

$query = array(
    'SELECT'    => 'c.id AS cid, c.cat_name, c.something f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster',

I need documentation or a paid helper/support? cool

Re: Using extensions to replace core code?

I'm not the best at SQL, but if you'd like to get an extra column from the table, you could do something like:

$query['SELECT'] .= ', c.something';

Notice the dot before the =, that means the string will be added to the end of the existing string smile