Форумы / Cotonti / Support / Plugin on index

Create a little plugin for index

Harker
#39506 04.05.2014 13:11

Hello to all,

I come towards you because I try to create a plugin which displays on page index. I need that he shows only the information of 4 back pages(news)

I tried some solution but I become muddled with =>   $t = new XTemplate(cot_tplfile.....

Here is my code:

mininews.index.php

/* ====================
[BEGIN_COT_EXT]
Hooks=index.tags
Tags=index.tpl:{MININEWS}
[END_COT_EXT]
==================== */

defined('COT_CODE') or die('Wrong URL');

	$t = new XTemplate(cot_tplfile('mininews', 'plug'));

	$sql = $db->query("SELECT page_alias, page_title, page_avatar 
			   FROM $db_pages 
			   WHERE page_cat = 'news' 
			   ORDER BY page_id DESC 
			   Limit 4");

	while($row = $sql->fetch())
	{
    	$t->assign(array(
            'PAGESS_ALIAS' => htmlspecialchars($row['page_alias']),
	    'PAGESS_TITLE' => htmlspecialchars($row['page_title']),
	    'PAGESS_AVATAR' => $row['page_avatar']
    	));
	    $t->parse('MININEWS');
	}

mininews.index.tpl

<!-- BEGIN: MININEWS -->
<div>{PAGESS_ALIAS}{PAGESS_TITLE}{PAGESS_AVATAR}</div>
<!-- END: MININEWS -->

mininews.setup.php

/* ====================
[BEGIN_COT_EXT]
Code=mininews
Name=mininews
Description=provides mininews
Version=1.0
Date=04/20/2014
Author=Stygz
Copyright=
Notes=Just A Test.
Auth_guests=R
Lock_guests=12345A
Auth_members=RW
Lock_members=12345A
[END_COT_EXT]
==================== */

defined('COT_CODE') or die('Wrong URL');

 

 

With this code, nothing displays and I do not manage to understand why :'(

If you have a little of time, could you help me :D