Jump to content


[Tutorial] How to copy a module (ex: reviews)


  • You cannot reply to this topic
No replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 29 November 2005 - 07:24 AM

How to Copy Reviews to make new "Articles" module in M1.0


INDEX:

1) Add articles to index.php array
'articles'	  =>   "articles",
------------------------------------------------------------------------------
FUNCTIONS:

1) Add articles to mkportal/include/functions.php (function read_member)
$this->member['g_access_articles'] =  $row['g_access_articles'];
$this->member['g_send_articles'] =  $row['g_send_articles'];
$this->member['g_mod_articles'] =   $row['g_mod_articles'];
2) Add articles to mkportal/include/functions.php (function checklinkperm)
	//Articles begin
 if (stristr($url, 'ind=articles')) {
  if ($this->config['mod_articles']) {return TRUE;}
  if(!$mkportals->member['g_access_cp'] && !$this->member['g_access_articles']) {return TRUE;}
 
 }
 //Articles end
------------------------------------------------------------------------------
BOARD FUNCTIONS:

1) Add articles to mkportal/include/***_board_functions.php (function store_location)


IPB2 ipb_board_functions.php
//Articles begin
 case 'articles':
	 $location= "articles";
	break;
//Articles end
------------------------------------------------------------------------------
MODULE FILES:

1)Copy mkportal/modules/reviews/ directory
Name "mkportal/modules/articles/tpl_reviews.php" to "tpl_articles.php"

2)Find and Replace in index.php and tpl_articles.php. IMPORTANT: use case sensitive search and replace!

* FIND "review"
REPLACE WITH "article"

* FIND "Review"
REPLACE WITH "Article"

* FIND "rev"
REPLACE WITH "art"

* FIND "re_"
REPLACE WITH "ar_" !!! Be careful not to replace "store_location" in index.php !!!

------------------------------------------------------------------------------
LANG FILES:

1) Copy mkportal/lang/*/lang_review.php
Name new file lang_article.php

2)Find and Replace in lang_article.php. IMPORTANT: use case sensitive search and replace!

* FIND "review"
REPLACE WITH "article"

* FIND "rev"
REPLACE WITH "art"

* FIND "re_"
REPLACE WITH "ar_"

* FIND "ad_re"
REPLACE WITH "ad_ar" !!! Be careful not to replace entries with "ad_req" !!!


3) Add to lang_admin.php
//Articles
$langmk['ad_article'] = "Articles";
$langmk['ad_p_accarticles'] = "Can view Articles?";
$langmk['ad_p_sendarticles'] = "Can Submit Articles?";
$langmk['ad_p_modarticles'] = "Can Moderate Articles?";
$langmk['ad_artsubmitted'] = "Articles waiting for Approval:";
4) Add to lang_global.php
//Articles
$langmk['articles'] = "Articles";
$langmk['in_articles'] = "Inside the Articles Area";
------------------------------------------------------------------------------
ADMIN FILES:

1) Add articles to mkportal/admin.php array

'ad_article'	  =>   "ad_article",
2) Copy mkportal/admin/ad_review.php
Name new file ad_article.php

3)Find and Replace in ad_article.php. IMPORTANT: use case sensitive search and replace!

* FIND "review"
REPLACE WITH "article"

* FIND "Review"
REPLACE WITH "Article"

* FIND "re_"
REPLACE WITH "ar_"

4) Add the Articles link to mkportal/admin/ad_menu.php

* FIND:
 <tr><td width="100%" class="tdblock"><img src="$this->images/frec.gif" align="left" alt="" /> <a class="uno" href="$this->mkurl/admin.php?ind=ad_quote">{$this->lang['ad_quote']}</a></td></tr>
*ADD AFTER:
	   
 <tr><td width="100%" class="tdblock"><img src="$this->images/frec.gif" align="left" alt="" /> <a class="uno" href="$this->mkurl/admin.php?ind=ad_article">{$this->lang['ad_article']}</a></td></tr>
5) Add the Articles edits to mkportal/admin/ad_approvals.php

(see file)


6) Add the Articles edits to mkportal/admin/ad_perms.php

(see file)

------------------------------------------------------------------------------
IMAGES:

1) Copy rev.gif and rev1.gif in mkportal/templates/*/images/
Name new images art.gif and art1.gif

------------------------------------------------------------------------------
DATABASE:

1) Alter Reviews database queries from mk_install.php to be the new articles database entries...


INSERT INTO `mkp_config` (`chiave`, `valore`) VALUES ('mod_articles', '0');
INSERT INTO `mkp_config` (`chiave`, `valore`) VALUES ('art_sec_page', '10');
INSERT INTO `mkp_config` (`chiave`, `valore`) VALUES ('art_file_page', '10');
INSERT INTO `mkp_config` (`chiave`, `valore`) VALUES ('approval_article', '0');


ALTER TABLE `mkp_pgroups` ADD `g_access_articles` tinyint(1) NOT NULL default '0';
ALTER TABLE `mkp_pgroups` ADD `g_send_articles` tinyint(1) NOT NULL default '0';
ALTER TABLE `mkp_pgroups` ADD `g_mod_articles` tinyint(1) NOT NULL default '0';

CREATE TABLE `mkp_articles` (
 `id` int(10) NOT NULL auto_increment,
 `id_cat` int(10) NOT NULL default '0',
 `title` varchar(255) NOT NULL,
 `description` varchar(255) NOT NULL,
 `field1` varchar(255) NOT NULL,
 `field2` varchar(255) NOT NULL,
 `field3` varchar(255) NOT NULL,
 `field4` varchar(255) NOT NULL,
 `field5` varchar(255) NOT NULL,
 `field6` varchar(255) NOT NULL,
 `field7` text NOT NULL,
 `image` varchar(255) NOT NULL,
 `article` text NOT NULL,
 `author` varchar(40) NOT NULL,
 `idauth` int(10) NOT NULL default '0',
 `click` int(10) NOT NULL default '0',
 `rate` varchar(10) NOT NULL,
 `trate` int(10) NOT NULL default '0',
 `date` int(10) NOT NULL default '0',
 `validate` tinyint(1) NOT NULL default '1',
 PRIMARY KEY  (`id`)
);

CREATE TABLE `mkp_articles_comments` (
 `id` int(10) NOT NULL auto_increment,
 `identry` int(10) NOT NULL default '0',
 `autore` varchar(40) NOT NULL,
 `testo` text NOT NULL,
 `data` int(10) NOT NULL default '0',
 `scambio` tinyint(1) NOT NULL default '0',
 `id_autore` int(10) NOT NULL default '0',
 PRIMARY KEY  (`id`)
);

CREATE TABLE `mkp_articles_sections` (
 `id` int(10) NOT NULL auto_increment,
 `title` varchar(60) NOT NULL default '',
 `description` varchar(255) NOT NULL default '',
 `field1` varchar(60) NOT NULL,
 `field2` varchar(60) NOT NULL,
 `field3` varchar(60) NOT NULL,
 `field4` varchar(60) NOT NULL,
 `field5` varchar(60) NOT NULL,
 `field6` varchar(60) NOT NULL,
 `field7` text NOT NULL,
 `position` int(4) NOT NULL default '0',
 PRIMARY KEY  (`id`)
);
DEMO: http://www.visibleso...hp?ind=articles

Copying a module is not that easy and one little syntax error will cause big problems. If it helps you, good. If this tutorial helps you good, if not then at least you can see that copying a module is fairly complicated.

-=DKC=-


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users