Foren / Cotonti / Support / [XTemplate]

djmadclass
#1 1. Mai 2009, 22:57
any idea why im getting this parse error.

[XTemplate]
    * parse: blockname [HEADER] does not exist

[XTemplate]

    * parse: blockname [FOOTER.USER] does not exist

    * parse: blockname [FOOTER] does not exist

i dont get this error on seditio. here the plugin code.

<?PHP
/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/notifications/notifications.header.php
Version=
Updated=
Type=Plugin
Author=
Description=
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=notifications
Part=
File=notifications.header
Hooks=header.tags
Tags=
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]

==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

if ($e=='notifications') {
$mskin = "plugins/notifications/notifications.header.tpl";
$t = new XTemplate ($mskin); } 


?>
JonnyM
#2 2. Mai 2009, 20:54
My guess is that the loading of a new skin file notifications.header.tpl in header.php* one row before the code calls parse("HEADER") makes XTemplate unhappy.
Why it works in Seditio I can't say though.
Btw, why is a skin file loaded there in the first place ?

EDIT: It might work if the skin file is loaded before header.tpl. Just change the hook to header.main

*that's where the header.tags files are loaded
Orkan
#3 3. Mai 2009, 06:20
$t is one of reserved variables used by Cotonti core, you should never use it unless you know what you're doing.
Perl - the only language that looks the same before and after RSA encryption.
djmadclass
#4 7. Mai 2009, 19:57
hey, thanks guys for the feed back. im creating a notification plugin using jquery jgrowl and json. i havent fully look at all the new changes of cotonti.

the problems was in tpl, i had it like sedito.

<!--- BEGAIN MAIN --->

but in cotonti, its.

<!--- HEADER --->

for now i created this plugin for pm notifications, on till i can either find some one who knows how to code jquery to help me out or i figure it out some how. ill just leave it for pm and share it when it done.

i want to be able to exit the notifications and update the sql but the only way i can think of is to add a link to update the sql. the problem is that when you click on it. it will redirect you.

here a link to jgrowl so you guys can see what im talking about.
GHengeveld
#5 8. Mai 2009, 00:19
Why not update the existing notification plugin to use jgrowl?
And by the way, you can't actually 'code' jquery, because jquery is only a framework for coding javascript, it's not a language itself.
Kilandor
#6 8. Mai 2009, 00:28
Um, no w don't use <!--- HEADER ---> the problem is your calling a $t a new skin file before header is done with it And so its trying to use your title

And as kordahil said, there's no need to add a whole new header file like that you can use various things liek $out or the different vars avail to plugs to add things in the header if need be.
djmadclass
#7 9. Mai 2009, 19:05
here's what i have so far. i kept it just for pm for now and no setting. im not finished with it but you guys can get an idea what i was doing.

i wanted to bypass the header and the footer because this is the only way i can think of, to do either xml or json arrays out put.

also, this is why i didnt use the notifir plugin and i meant to say...

<!--- BEGAIN: HEADER --->

notifications.header.php

<?PHP
/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/notifications/notifications.header.php
Version=
Updated=
Type=Plugin
Author=DJMADCLASS
Description=
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=notifications
Part=header
File=notifications.header
Hooks=header.tags
Tags=
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]

==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }


if ($e=='notifications') {
$mskin = "plugins/notifications/notifications.header.tpl";
$t = new XTemplate ($mskin); }


?>

notifications.header.tpl
<!-- BEGIN: HEADER -->
<!-- END: HEADER -->

notificatons.footer.php

<?PHP
/* ====================
Seditio - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/notifications/notifications.footer.php
Version=
Updated=
Type=Plugin
Author=DJMADCLASS
Description=
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=notifications
Part=footer
File=notifications.footer
Hooks=footer.tags
Tags=
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]

==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }


if ($e=='notifications') {
$mskin = "plugins/notifications/notifications.footer.tpl";
$t = new XTemplate ($mskin); }


?>

notifications.footer.tpl

<!-- BEGIN: FOOTER -->
<!-- END: FOOTER -->

notifications.php

<?php
/* ====================
Land Down Under - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/notifications/notifications.php
Version=
Updated=
Type=Plugin
Author=DJMADCLASS
Description=JQUERY JGROWL NOTIFICATIONS
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=notifications
Part=main
File=notifications
Hooks=standalone
Tags=
Order=10
[END_SED_EXTPLUGIN]
==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

// USER GROUP LEVEL ////////////////////////////////////////////////////////////
if (!$usr['isadmin'] || $userid=='')
	{ $userid = $usr['id']; }

if ($userid!=$usr['id'])
	{ sed_block($usr['isadmin']); }

$user_info = sed_userinfo($userid);
$maingroup = ($userid==0) ? 1 : $user_info['user_maingrp'];
$userlevel = $sed_groups[$maingroup]['level'];

$a = sed_import('a','G','TXT');
$id = sed_import('id','P','INT');

// SKIN ////////////////////////////////////////////////////////////////////////
$mskin = "plugins/notifications/notifications.tpl";
$t=new XTemplate ($mskin);


if ($a=='delete') {
$sql = sed_sql_query("SELECT * FROM $db_pm WHERE pm_id='$id' LIMIT 1");

if ($row = sed_sql_fetchassoc($sql)) {
if ($cfg['trash_pm'] && $pm_state < 3) {

sed_trash_put('pm', $L['Private_Messages']." #".$id." ".$row['pm_title']." (".$row['pm_fromuser'].")", $id, $row); }
$sql = sed_sql_query("DELETE FROM $db_pm WHERE pm_id='$id'"); }

//header("Location: ");
exit; }


// START ARRAY /////////////////////////////////////////////////////////////////
$aResults = array();


// PM NOTIFICATION /////////////////////////////////////////////////////////////
if (!$cfg['disable_pm']) {
$usr_pm = sed_sql_query("SELECT * FROM $db_pm WHERE pm_touserid='".$usr['id']."' AND pm_state=0");
$c1=0;

while($notifi_pm = sed_sql_fetcharray($usr_pm)){

$notifi_pm_id = $notifi_pm['pm_id'];
$notifi_pm_title = sed_cutstring($notifi_pm['pm_title'], 40); // LIMIT HOW LONG YOU WANTED
$notifi_pm_text = $notifi_pm['pm_text'];
$notifi_pm_text = str_replace('"', '', $notifi_pm_text); // ARE NOT ALLOWED
$notifi_pm_text = str_replace("'", '', $notifi_pm_text); // ARE NOT ALLOWED
$notifi_pm_text = str_replace(',', '', $notifi_pm_text); // ARE NOT ALLOWED
$notifi_pm_text = sed_cutstring($notifi_pm_text, 256); // LIMIT HOW LONG YOU WANTED
$notifi_pm_text = wordwrap($notifi_pm_text, 30, "<br>"); // LIMIT HOW MANY CHAR PER LINE


$notifi_pm_from_userinfo = sed_userinfo($notifi_pm['pm_fromuserid']);
$notifi_pm_fromavator = (!empty($notifi_pm_from_userinfo['user_avatar'])) ? '<img src='.$notifi_pm_from_userinfo['user_avatar'].' align=left width=50 vspace=2px hspace=2>' : '';
$notifi_pm_fromname = strtoupper($notifi_pm_from_userinfo['user_name']);

$notifi_pm_icon = '<img src=skins/'.$skin.'/img/system/icon-pm.gif hspace=2px> '; // PM ICON

$notifi_pm_sticky = 'true'; // TRUE MAKE IT STICKY

$notifi_pm_title_output = $notifi_pm_icon.$notifi_pm_title; // ICON AND TITLE
$notifi_pm_text_output = $notifi_pm_fromavator.'MSG FROM: '.$notifi_pm_fromname.'<br><br>'.$notifi_pm_text; // AVATOR, SUBJECT AND MESSAGE


$c1++;
$aResults[] = array("id"=>($c1), "pm_id"=>$notifi_pm_id , "title"=>$notifi_pm_title_output, "text"=>$notifi_pm_text_output, "nsticky"=>$notifi_pm_sticky ); }

} // END PM NOTIFICATIONS //////////////////////////////////////////////////////




// JGROWL DATA.ITEMS ///////////////////////////////////////////////////////////
echo "{\"items\": [";
$arr = array();

for ($i=0;$i<count($aResults);$i++) {
$arr[] = "{\"id\": \"".$aResults[$i]['id']."\", \"pm_id\": \"".$aResults[$i]['pm_id']."\",  \"title\": \"".$aResults[$i]['title']."\", \"text\": \"".$aResults[$i]['text']."\", \"nsticky\": \"".$aResults[$i]['nsticky']."\"}"; }

echo implode(", ", $arr);
echo "]}";


?>

notificatons.setup.php

<?PHP
/* ====================
Land Down Under - Website engine
Copyright Neocrome
http://www.neocrome.net

[BEGIN_SED]
File=plugins/notifications/notifications.setup.php
Version=
Updated=
Type=Plugin
Author=DJMADCLASS
Description=JQUERY JGROWL NOTIFICATIONS
[END_SED]

[BEGIN_SED_EXTPLUGIN]
Code=notifications
Name=NOTIFICATION WITH JQUERY JGROWL
Description=
Version=
Author=
Updated=
Copyright=
Notes=
SQL=
Auth_guests=R
Lock_guests=RW12345A
Auth_members=RW
Lock_members=RW12345A
[END_SED_EXTPLUGIN]

[BEGIN_SED_EXTPLUGIN_CONFIG]
[END_SED_EXTPLUGIN_CONFIG]
==================== */

if ( !defined('SED_CODE') ) { die("Wrong URL."); }

?>

notifications.tpl

<!-- BEGIN: MAIN -->
<!-- END: MAIN -->
[/][/]
Orkan
#8 9. Mai 2009, 19:36
Hey, look at this file: http://trac.cotonti.com/browser/trunk/plugins/markitup/markitup.ajax.php

For AJAX use Hooks=ajax, not Hooks=standalone. You only need 2 files: notificatons.setup.php, notifications.php All the other files just does nothing so why you make them?

Also in notifications.php, make one loop instead of two...


Anyway, nice idea. Keep it up :)
Perl - the only language that looks the same before and after RSA encryption.
djmadclass
#9 10. Mai 2009, 05:56
i didnt know about hooks=ajax, ill have a look at it and thanks.