Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Hondo - toukokuu 15, 2014, 07:31:45 AP

Otsikko: need help for a modification
Kirjoitti: Hondo - toukokuu 15, 2014, 07:31:45 AP
Hello,
I have written my first modification - but when I want to install it only a few operations of the files are displayed. For Example, in File Calendar.php only 2 of 6 operations are displayed but I don't find the mistake.
Can you please help me?

Andreas
Otsikko: Re: need help for a modification
Kirjoitti: Shambles - toukokuu 15, 2014, 08:39:02 AP
<file name="$themedir/Post.template.php">
<operation>
<search position="replace"><![CDATA[ if (!empty($modSettings['cal_allowspan']) || ($context['event']['new'] && $context['is_new_post']))]]></replace>


Notepad++ highlights a discrepancy in your tags ;)
Otsikko: Re: need help for a modification
Kirjoitti: Hondo - toukokuu 15, 2014, 10:18:36 AP
Yes you are right ;-)
now it works
Otsikko: Re: need help for a modification
Kirjoitti: Hondo - toukokuu 15, 2014, 11:28:07 AP
Another Problem in installDatabase.php of the Mod.
I get the error:
LainaaYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'calendar ADD COLUMN location VARCHAR(60)' at line 1
Datei: /is/htdocs/wp1007012_HAK7TONUQ3/www/forum/Packages/temp/installDatabase.php
Zeile: 31

Here the code of installDatabase.php:
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
  require_once(dirname(__FILE__) . '/SSI.php');
if (version_compare('4', preg_replace('~\-.+?$~', '', min(mysql_get_server_info(), mysql_get_client_info()))) > 0)
$schema_type = ' TYPE=MyISAM';
else
$schema_type = ' ENGINE=MyISAM';

// Category Table
$smcFunc['db_query']('', "CREATE TABLE IF NOT EXISTS {db_prefix}calendar_cat(
id_cat mediumint(8) NOT NULL auto_increment,
cat_order tinyint(4) NOT NULL default '0',
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id_cat)) $schema_type");

// Add location to table calendar
$smcFunc['db_query']('', "Alter TABLE {db_prefix}calendar ADD COLUMN location VARCHAR(60)");


I don't see any mistake.
Please help again.

Andreas
Otsikko: Re: need help for a modification
Kirjoitti: Arantor - toukokuu 15, 2014, 11:31:45 AP
I'd suggest using $smcFunc['db_create_table'] (which will not only deal with the 'if not exists' part if you want, it will also safely abstract away the TYPE or ENGINE part of the deal... or even work on PostgreSQL and SQLite if you want to distribute your mod) and $smcFunc['db_add_column'].

In your case, {db_prefix} will not be what you think it is inside an SSI context and thus you cannot use it for schema changing events inside SSI. (In SSI, SMF does not select a database and internally, db_prefix is rewritten to include the database name in there)
Otsikko: Re: need help for a modification
Kirjoitti: Hondo - toukokuu 15, 2014, 11:46:16 AP
works now.
in packages/temp was stored an old version of the files, I deleted it and tried it again.
Otsikko: Re: need help for a modification
Kirjoitti: Hondo - toukokuu 16, 2014, 03:30:54 AP
Sorry, need your help again.
My modification runs at the installer but no files are modified. Database installer works correkt.
What the hell is wrong?
Mod ist for SMF 2.x

Thanks Andreas
Otsikko: Re: need help for a modification
Kirjoitti: Hondo - toukokuu 20, 2014, 04:28:55 IP
Nobody?
Please help me!
Otsikko: Re: need help for a modification
Kirjoitti: Arantor - toukokuu 20, 2014, 04:32:43 IP
I don't see why I should help you if you don't take on board the advice already given. Makes me somewhat against spending any more time trying to help you.
Otsikko: Re: need help for a modification
Kirjoitti: Hondo - toukokuu 20, 2014, 05:16:05 IP
Yes but Table will be created and Modificaiton of Table works.
So there can be no error in installDatabase.php?!
Or what do you mean? Sorry for my bad english.