Create a little plugin for index
Harker |
|
---|---|
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 |
aiwass |
|
---|---|
Why don't you use recentitems plugin instead? It does what you are trying to achieve.Just change the template (.tpl) to how you want it to look. Take all that money that we spend on weapons and defences each year and instead spend it feeding and clothing and educating the poor of the world, which it would many times over, not one human being excluded, and we could explore space, together, both inner and outer, forever, in peace. - Bill Hicks
https://evlear.com |
Harker |
|
---|---|
Hi Aiwass, I am going to try to explain but I manage not very well in English. In fact, I already use 'recentitems' other leave in the design. Actually, i use the plugin 'News' and i also parametrized him to see 4 news. For the design of my website, I need both. (news & my_plug[mininews]) You know how to see on the image what I wish to make That's why I wish to make this plugin, to show 4 right images
Added 36 minutes later: Later of numerous copy/paste, I finally managed to show what I wished \o/ To be frank, I have no idea of why it works. This is what I modified : mininews.index.php
/* ==================== [BEGIN_COT_EXT] Hooks=index.tags Tags=index.tpl:{MININEWS} [END_COT_EXT] ==================== */ defined('COT_CODE') or die('Wrong URL'); $ttt = new XTemplate(cot_tplfile('mininews.index', '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"); /* === Hook - Part1 === */ $extp = cot_getextplugins('mininews.index.tags'); /* ===== */ foreach ($sql->fetchAll() as $row) { $ttt->assign(array( 'PAGESS_ALIAS' => htmlspecialchars($row['page_alias']), 'PAGESS_TITLE' => htmlspecialchars($row['page_title']), 'PAGESS_AVATAR' => $row['page_avatar'] )); /* === Hook - Part2 === */ foreach ($extp as $pl) { include $pl; } /* ===== */ $ttt->parse('MININEWS'); } $t->assign('MININEWS', $ttt->text('MININEWS'));
|
|
Bu konu Harker tarafından düzenlendi(2014-05-04 21:46, 10 yıllar önce) |
Kort |
|
---|---|
This can be easily accomplished with the pagelist plugin. SED.by - создание сайтов, разработка плагинов и тем для Котонти
|
Harker |
|
---|---|
That's it of step read the descriptions and to pass next to an interesting plugin, thank you very much :D |
Macik |
|
---|---|
Moreover, this can be accomplished by common News plugin — http://screenshot.galaxyhost.org/img/20140507-2pa-57kb.jpg https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |