1
zer0fill
prevent xoops module installer from parsing the templates? (crude patch)
  • 2004/1/9 7:23

  • zer0fill

  • Not too shy to talk

  • Posts: 137

  • Since: 2003/12/2


Crude patch below. unsure if it will degrade the rest of the site


Is there a way to prevent XOOPS module installer from parsing the templates? My templates contain objects and the installer is failing because the object was never passed. I was thinking of an option like $modversion['parseTemplates'] = 0;

btw, it installs fine if i comment out the templates then "update" the module after uncommenting the templates.

2
Mithrandir
Re: prevent xoops module installer from parsing the templates?

And it is working fine if you comment out the templates?

I think you need to give a bit more info - especially the part about the errors you get during parsing - before I can judge if your suggestion is a good one or a bad one

3
skalpa
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/9 13:44

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


Actually you can't... But I'm surprised assigning objects breaks templates compilation .
What msg do you get ?

IMO, if your commenting / uncommenting method works, one possible workaround would be to enclose your xoops_version templates definitions within an if block and do something like this:
if ( module_is_installed ) {
 
$modversion['templates'] = ...
}


Like this, the lines would be skipped during the 1st install. Now the prob is that you have to figure out what to put in the if condition
Tell me if you managed to, if not I'll try finding something for ya tomorrow (I can't look at this right now).

Skalpa.>

4
messju
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/9 13:55

  • messju

  • Just popping in

  • Posts: 2

  • Since: 2004/1/8 2


just a note because you "": assigned objects don't break compilation, but registered ones do. a registered object is like a registered function: you need it at compile-time.

(just fyi: i only know <1% XOOPS (i just started), but i know some smarty)

greetings
messju

5
zer0fill
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/9 20:19

  • zer0fill

  • Not too shy to talk

  • Posts: 137

  • Since: 2003/12/2


The object was assigned by
Quote:

/*
HtmlVals() has all the href-locations, input names, form names, etc. i'm not hard-coding them because the designers (who don't know much about using "extended" urls like ?op=search and forms) will be editing my templates and i don't want any typos
*/
$xoopsTpl->assign_by_ref('html',new HtmlVals());

an example of it in use (flexsearch_search.html. grrrr why is [ code ] <br />'ing things with quotes? n/m. i'll use [ quote ] instead. weird)
Quote:

<form method="<{$html->FM_SEARCH()}>" name="<{$html->FN_SEARCH()}>" action="<{$html->FA_SEARCH()}>">
<{html_options options=$categories selected=$cat_sel}>
</form>

The error is
Quote:

<form name="
Fatal error: Call to a member function on a non-object in d:\domains\mycft.org\public_html\templates_c\db%3Aflexsearch_search.html on line 4

it shows that script error then installation just dies. the only way to "fix" it from that point is to re-install with the comment/uncomment workaround or use skalpa's "if" check. updating the module fixes the template problem but the admin-bar icon never gets set.

is there a reason it does the initial compile during installation, yet it does not if updated?

fwiw, my system is winxp pro w/ all critical patches, apache 1.3x, MySQL 4.0.17-nt, PHP 4.3.2. (i work on the site locally then upload it to a linux webhost)

Hey messju! (If you're messju from smarty.php.net forums ). Either way, welcome abord

6
zer0fill
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/9 22:09

  • zer0fill

  • Not too shy to talk

  • Posts: 137

  • Since: 2003/12/2


@skalpa

i traced the check to
$module_handler =& xoops_gethandler('module');
if (
$module_handler->getCount(new Criteria('dirname'$dirname)) != 0
{
    
$modversion['templates'][]['file'] = 'flexsearch_header.html';
    
$modversion['templates'][]['file'] = 'flexsearch_footer.html';
    
$modversion['templates'][]['file'] = 'flexsearch_index.html';
    
$modversion['templates'][]['file'] = 'flexsearch_search.html';
}

Before anyone says anything, PHP automatically increments empty square-brackets []; manually typing in numbers is NOT necessary

now the problem is making sure the user updates the module before using it.

7
Jakobo
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/10 0:10

  • Jakobo

  • Just popping in

  • Posts: 61

  • Since: 2003/12/18


If you are looking for a workaround, there is an option in modversion to execute a script after installation. It may be possible to run the module's update right at the end of installation, silent to the user.

(Though I have never tried it)

8
naish
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/11 9:48

  • naish

  • Just popping in

  • Posts: 21

  • Since: 2003/6/10


The problem described in this thread stems from the fact that XOOPS need to "run" the template in order to recompile it. This is a limitation in smarty AFAIK....

The best solution is to make smarty compile only, however there seems to be no function to do this.

The <{if $objectname}> seems to be the best workaround available..

This is not a good thing IMHO, but I currently don't know how to fix it.


9
skalpa
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/12 3:13

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


Quote:

is there a reason it does the initial compile during installation, yet it does not if updated?

IMO: no. But the output layer is the part I'm specifically investigating at the mo, so I believe this may change.

Quote:
Before anyone says anything, PHP automatically increments empty square-brackets []; manually typing in numbers is NOT necessary



Quote:
The problem described in this thread stems from the fact that XOOPS need to "run" the template in order to recompile it. This is a limitation in smarty AFAIK....

Actually the fact that modules aren't able to access the smarty engine instanciated during the install phase is a XOOPS limitation. Also, a template gets automatically compiled by smarty when it's accessed, so I'm not sure about the need for this initial compil (except that it's a way to check the templates syntax is correct).

@ 0000000000000000000000000000000000000000000

There's no way to ensure people update the module, but there's is an "onInstall" easter egg in XOOPS I described here.
At least you can use this to display a message to users telling them they have to update the module, until we can find something better...

Skalpa.>

10
zer0fill
Re: prevent xoops module installer from parsing the templates?
  • 2004/1/16 0:10

  • zer0fill

  • Not too shy to talk

  • Posts: 137

  • Since: 2003/12/2


bad news. it seems the only reason it was working was because i had a clone of the default template before installing the module. now i have to (i think): uninstall module, delete cloned template, re-clone template & set to default, reinstall module, update module so templates take effect.

[edit]
Yep. I had to do exactly that (above) to get it working again. It started going all screwy cause I had to do some changes to the main menu template
[/edit]

i hope there's a new version coming out that just dumps template info to the db rather than parsing/compiling it then dumping it.

[edit]
USE AT OWN RISK: If you use objects in your templates and want to prevent the xoops/smarty error when compiling do the following

Comment out the line (file: /class/template.php ~line 240)
$tpl->fetch('db:'.$file);

it's within the xoops_template_touch() function
I don't know the problems that might occur by doing this
[/edit]

Login

Who's Online

149 user(s) are online (100 user(s) are browsing Support Forums)


Members: 0


Guests: 149


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits