FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » Adding new template but it's not compiled
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Adding new template but it's not compiled [message #29128] Thu, 01 December 2005 04:18 Go to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
What I'm trying to do is modify the index.tmpl so a link is displayed to open a page.

That page will contain a JIRC Applet customized for each logged in user or a random username if the user is anonymous.

I've read the template help post and search the forum and read the docs but I'm stumped.

Here's what I did:

In the index.tmpl I added:

Quote:


....... SNIPPED .......
{TEMPLATE: usercp}
<br /><div class="ac">

<!-- This part -->
<table class="Chat" border="1" cellspacing="2" cellpadding="3"><tr><td class="wht"><a class="fb" href="{TEMPLATE: chatlink}">
ST: Unity Chat Room</a></td></tr></table></div><br />
<!-- up to here -->

{IF: _uid}<span class="GenText">{MSG: welcome_message}</span><br />{ENDIF}
....... SNIPPED .......



{TEMPLATE: chatlink} is defined as:

Quote:

{SECTION: chatlink}
{ROOT}?t=chat&amp;{DEF: _rsid}
{SECTION: END}


Pretty simple.

chat.tmpl contains:
Quote:

{PHP_FILE: input: chat.php.t; output: chat.php;}
{REF: security.tmpl}
{REF: logedin.tmpl}
{REF: footer.tmpl}
{REF: curtime.tmpl}
{REF: stats.tmpl}
{REF: show.tmpl}
{REF: quicklogin.tmpl}

{PAGE: CHATPAGE}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>{GVAR: FORUM_TITLE}{VAR: TITLE_EXTRA}</title>
{META-CONTENT-LANGUAGE}
<BASE HREF="{FULL_ROOT}">
<script language="javascript" src="lib.js" type="text/javascript"></script>
<link rel="StyleSheet" href="{THEME_ROOT}/forum.css" type="text/css" media="screen" title="Default FUDforum Theme">
</head>
<body>
{TEMPLATE: usercp}
{IF: _uid}<span class="GenText">{MSG: welcome_message}</span><br />{ENDIF}
<table class="wa" border="0" cellspacing="3" cellpadding="5"><tr><td class="ForumBackground">
<br /><div class="ac"><table class="Chat" border="1" cellspacing="2" cellpadding="3"><tr><td class="wht">
{VAR: ChatApplet}
</td></tr></table></div><br />
{IF: __fud_real_user__}{TEMPLATE: quick_login_loged_in}{ELSE}{TEMPLATE: quick_login_on}{END}
{IF: $logedin || $forum_info}{TEMPLATE: loged_in_list}{ENDIF}
{TEMPLATE: curtime}
{TEMPLATE-DATA: page_stats}
{TEMPLATE: footer}
{PAGE: END}



chat.php.t contains:
Quote:

/*{PRE_HTML_PHP}*/

$TITLE_EXTRA = ': {MSG: chat_title}';

/*{POST_HTML_PHP}*/
$ChatApplet = '<applet code=IRCApplet.class archive='irc.jar,pixx.jar' width=640 height=400>
<param name='CABINETS' value='irc.cab,securedirc.cab,pixx.cab'>

<param name='nick' value='{VAR: usr->alias}'>
<param name='alternatenick' value='Anon-???'>
<param name='fullname' value='{VAR: usr->alias}'>
<param name='host' value='irc.freenode.net'>
<param name='gui' value='pixx'>

<param name='quitmessage' value='Onward!'>
<param name='asl' value='false'>
<param name='useinfo' value='false'>

<param name='command1' value='/join #ST-Unity'>
<param name='command2' value='/msg nickserv IDENTIFY Jysuis6'>

<param name='authorizedjoinlist' value='#ST-Unity'>

<param name='style:bitmapsmileys' value='true'>
<param name='style:smiley1' value=':) img/sourire.gif'>
<param name='style:smiley2' value=':-) img/sourire.gif'>
<param name='style:smiley3' value=':-D img/content.gif'>
<param name='style:smiley4' value=':d img/content.gif'>
<param name='style:smiley24' value=':D img/content.gif'>
<param name='style:smiley5' value=':-O img/OH-2.gif'>
<param name='style:smiley6' value=':o img/OH-1.gif'>
<param name='style:smiley7' value=':-P img/langue.gif'>
<param name='style:smiley8' value=':p img/langue.gif'>
<param name='style:smiley26' value=':P img/langue.gif'>
<param name='style:smiley9' value=';-) img/clin-oeuil.gif'>
<param name='style:smiley10' value=';) img/clin-oeuil.gif'>
<param name='style:smiley11' value=':-( img/triste.gif'>
<param name='style:smiley12' value=':( img/triste.gif'>
<param name='style:smiley13' value=':-| img/OH-3.gif'>
<param name='style:smiley14' value=':| img/OH-3.gif'>
<param name='style:smiley15' value=':'( img/pleure.gif'>
<param name='style:smiley16' value=':$ img/rouge.gif'>
<param name='style:smiley17' value=':-$ img/rouge.gif'>
<param name='style:smiley18' value='(H) img/cool.gif'>
<param name='style:smiley19' value='(h) img/cool.gif'>
<param name='style:smiley20' value=':-@ img/enerve1.gif'>
<param name='style:smiley21' value=':@ img/enerve2.gif'>
<param name='style:smiley22' value=':-S img/roll-eyes.gif'>
<param name='style:smiley25' value=':S img/roll-eyes.gif'>
<param name='style:smiley23' value=':s img/roll-eyes.gif'>
<param name='style:backgroundimage' value='false'>
<param name='style:backgroundimage1' value='all all 0 background.gif'>
<param name='style:sourcefontrule1' value='all all Serif 12'>
<param name='style:floatingasl' value='true'>

<param name='pixx:timestamp' value='true'>
<param name='pixx:highlight' value='true'>
<param name='pixx:highlightnick' value='true'>
<param name='pixx:nickfield' value='true'>
<param name='pixx:styleselector' value='true'>
<param name='pixx:setfontonstyle' value='true'>

</applet>'

/*{POST_PAGE_PHP_CODE}*/
?>
{TEMPLATE: CHATPAGE}


If I {REF: chat.tmpl} in index.tmpl fud will inline the page which I don't want it to, obviously. It will generate the chat.php file but clicking on it will give a white page.

I thought simply having the .tmpl in the theme directory would have it compiled but it seems this is not the case so I'm guessing it has to be included (or REF'ed if you prefer) somewhere but trying to do so gave me white pages...

From what I could read I'm doing it right. The link does display when browsing the index but clicking on it brings the normal index page. Obviously the chat.php isn't generated since it's not in the theme directory. (I rename the chat.php before rebuilding so it doesn't lead to false results)

I need to have the chat.tmpl and chat.php.t to be compiled and called using index.php?t=chat&rid=X

Maybe I've worked on it for so long that I'm blind to see... Anyway, a hand would be appreciated.

Thanks.
Re: Adding new template but it's not compiled [message #29140 is a reply to message #29128] Thu, 01 December 2005 15:48 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Your PHP script contains parser errors, you are enclosing the string in single quotes and then using single quotes inside it. I recommend you create the string by using heredoc syntax.

FUDforum Core Developer
Re: Adding new template but it's not compiled [message #29155 is a reply to message #29140] Fri, 02 December 2005 14:35 Go to previous messageGo to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
Thanks for the answer, I'll use that, though that won't solve my problem.

A simple question: If I have a file.tmpl not referenced by other files, will it be compiled or not?

[Updated on: Fri, 02 December 2005 14:35]

Report message to a moderator

Re: Adding new template but it's not compiled [message #29158 is a reply to message #29155] Fri, 02 December 2005 15:22 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
it will be compiled.

FUDforum Core Developer
Re: Adding new template but it's not compiled [message #29172 is a reply to message #29158] Fri, 02 December 2005 16:59 Go to previous messageGo to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
Ilia wrote on Fri, 02 December 2005 10:22

it will be compiled.


In that case I think I've got a problem because if I don't {REF: } a .tmpl file, the PHP_FILE won't be compiled.

My chat.tmpl starts with:

Quote:

{PHP_FILE: input: chat.php.t; output: chat.php;}


Unless I {REF: chat.tmpl} no chat.php is generated. And if I do REF: it, it'll be inlined in the REF'ering file and that's not something I want. (that would restart the chat applet every time the index is loaded)

Am I making sense? Very Happy It's possible I'm misunderstanding something here... Neutral
Re: Adding new template but it's not compiled [message #29174 is a reply to message #29172] Fri, 02 December 2005 17:11 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
REF is definately not required for a tmpl file to be built. If you have a .tmpl file and it hash {PHP_FILE:} component in it, it will be built as long as .tmpl file is present in the tmpl/ directory of the theme you are building.

FUDforum Core Developer
Re: Adding new template but it's not compiled [message #29175 is a reply to message #29174] Fri, 02 December 2005 17:21 Go to previous messageGo to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
Well, from what you're saying, there's probably something wrong either with the code or in my install, somehow. because if I don't REF it, it won't be compiled.

I'm using 2.7.3 and except for a theme there was no other modifications to the source files.

I read a post dating from some time ago about a similar issue and I'm wondering if that could be it. There was some kind of bug which was making it act the exact same way it's acting right now (not compiling .tmpl files). Could be it possible this was put back into the code? I'll try to find that post in a bit.
Re: Adding new template but it's not compiled [message #29176 is a reply to message #29175] Fri, 02 December 2005 17:26 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
You can debug the issue by adding debug code to the compile_all() function inside compilter.inc, specifically the code inside the
<?php
foreach (glob($GLOBALS['DATA_DIR'].'/thm/default/tmpl/*.tmpl') as $fe) {
?>

loop.


FUDforum Core Developer
Re: Adding new template but it's not compiled [message #29194 is a reply to message #29176] Sat, 03 December 2005 04:12 Go to previous messageGo to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
Thanks for the answer.

Sad thing is this is over my head and knowledge. If someone could try to have a dummy .tmpl file be compiled it would be much appreciated. I know that Fud doesn't want to compile it if it's not REF'ed here.

My knowledge of php is pretty sketchy except for the obvious. I spent part of the afternoon trying to come up with a way to either debug some info out of the script or work on having it compiled with no results.

So right now I'm thinking about using an almost static file with a couple of vars that will hopefully be echo'ed correctly.
Re: Adding new template but it's not compiled [message #29199 is a reply to message #29194] Sat, 03 December 2005 17:12 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Send me your chat.tmpl and chat.php.t and I'll give it a shot on my test system.

FUDforum Core Developer
Re: Adding new template but it's not compiled [message #29225 is a reply to message #29128] Mon, 05 December 2005 04:35 Go to previous messageGo to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
Hey Ilia,

I had some time yesterday to look at the code in a debugger and found two (minor) bugs and I think the culprit which was making my theme not compiling every .tmpl files.

On line 593 of compiler.inc there's a missing "/" before il8n/ here:
<?php
$file1 
$GLOBALS['DATA_DIR'].'thm/'.$tset.'i18n/'.$lang.'/charset';
# should be
$file1 $GLOBALS['DATA_DIR'].'thm/'.$tset.'/i18n/'.$lang.'/charset';
?>


Also, on line 615, there's a "/" before thm/ and there shouldn't have one. Since the DATA_DIR is already ending with a slash, the one before thm is wrong. Shown here:
<?php
$prim_msg_file 
$GLOBALS['DATA_DIR'].'/thm/'.$cmpl['tset'].'/i18n/'.$cmpl['lang'].'/msg';
# should be
$prim_msg_file $GLOBALS['DATA_DIR'].'thm/'.$cmpl['tset'].'/i18n/'.$cmpl['lang'].'/msg';
?>


Finally, the line 629 should be:
<?php
foreach (glob($GLOBALS['DATA_DIR'].'thm/'.$cmpl['tset'].'/tmpl/*.tmpl') as $fe)

# and not:

foreach (glob($GLOBALS['DATA_DIR'].'thm/default/tmpl/*.tmpl') as $fe)
?>


Now that last one I'm not too sure if it would break something else but after reading through the code and rebuilding both the default and my theme there didn't seem to be anything wrong... The way it is fixed will compile ALL files ending with .tmpl that they are REF'ed or not. Anyway, as I said it worked fine here.

Could anyone reproduce it if possible? If you want me to still send the .tmpl and .php.t files I can do so Ilia. Just let me know.
Re: Adding new template but it's not compiled [message #29227 is a reply to message #29225] Mon, 05 December 2005 04:42 Go to previous messageGo to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
Just thinking about it... You want me to repost the first two bugs in the Bugs forum (and the third if it's confirmed)?
Re: Adding new template but it's not compiled [message #29239 is a reply to message #29227] Mon, 05 December 2005 16:38 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
Fixed in cvs, here is the patch:
chttp://cvs.prohost.org/c/index.cgi/FUDforum/chngview?cn=7474


FUDforum Core Developer
Re: Adding new template but it's not compiled [message #29246 is a reply to message #29239] Mon, 05 December 2005 19:06 Go to previous messageGo to next message
MadJack is currently offline  MadJack   Canada
Messages: 19
Registered: November 2005
Location: Qc
Karma: 0
Junior Member
Thanks for the fix Ilia.

I'm wondering why you didn't include the line 615 fix though. Any reason?

<?php
$prim_msg_file 
$GLOBALS['DATA_DIR'].'/thm/'.$cmpl['tset'].'/i18n/'.$cmpl['lang'].'/msg'
# should be 
$prim_msg_file $GLOBALS['DATA_DIR'].'thm/'.$cmpl['tset'].'/i18n/'.$cmpl['lang'].'/msg';
?>


Also, there's something nagging me... If I add a .tmpl to the default theme, would it get automatically added to a different theme?
Re: Adding new template but it's not compiled [message #29248 is a reply to message #29246] Mon, 05 December 2005 19:38 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The CVS version does not have the leading / already, so this change was not necessary.

If a template file is added to the default theme it will appear in other themes as well.


FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: database server ip address
Next Topic: Avatar Admin Delete Feature
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 05:01:08 GMT 2024

Total time taken to generate the page: 0.02832 seconds