31
phatjew
Re: Reviews Module??
  • 2003/11/24 17:39

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


BTW, if you are desperate, check out Lykos Reviews here:


http://www.lykoszine.co.uk/modules/mydownloads/viewcat.php?cid=3

Good stuff, that.



32
phatjew
Re: Reviews Module??
  • 2003/11/24 17:36

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

tom wrote:

Any chance of being cheaky and asking for a link to show us a demo of your working progress.

Thanks


Like I said, I don't have a demo up because it is only running on my local machine at the moment. I have to get a live XOOPS site up before I can show the module, and that is probably at least a week away.

Having said that, there have been so many requests to see what I'm working on, I'll try to get the beta up ASAP. It won't be fully functional, but at least it will be something.

--Rafi



33
phatjew
Re: Reviews Module??
  • 2003/11/24 16:14

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


oops, submitted twice.



34
phatjew
Re: Reviews Module??
  • 2003/11/24 16:14

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


I am currently writing a reviews module that I hope to release within the next few weeks (beta). I am currently adding some admin/config functionality as well as converting my first draft hacking to templates and such. I don't have a demo up, but I will post here as soon as I have anything ready.




35
phatjew
Re: template not automatically recompiled
  • 2003/11/21 14:53

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

MithyT2 wrote:
How do you use that one?


I am writing a reviews module called PJReviews. (I hope to release it soon -- I am adding more admin functionality, converting to templates, and integratng more XOOPS code (xoopsForm in particular) to make it easier for others to use and modify.)

Anyway, in my module's index.php page, I have an if/elseif block to determine what to display, like the front page, a full review, or the results of a search. Inside each of these if{} block, I have code like this:

recompileTemplate('pjreviews','pjreviews_index.html');
recompileTemplate('pjreviews','pjreviews_searchbox.html');
$xoopsOption['template_main'] = 'pjreviews_index.html';


Where 'pjreviews_searchbox.html' is a template file included within 'pjreviews_index.html'

When I am ready to go live, I will simply comment out the "recompileTemplate" lines. However, right now I am constantly making changes to templates, and it saves me tons of time to have them automatically reloaded from the file into the database (the hard part) and recompiled (the easy part). Note that I do not have to explicity clear the cache every time, because the xoops_template_touch() function does that for me.

Hope that answers your question.



36
phatjew
Re: template not automatically recompiled
  • 2003/11/20 19:53

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Thanks for the advice, everyone.

In the end, I had to pull code from class/template.php, kernel/tplfile.php, and modules/system/admin/modulesadmin/modulesadmin.php.

Below is, I believe, a self-contained template recompiler function. It returns false if the update did not succeed, true otherwise. It can easily be made more generic, by basing it on a module id instead of a specific template, but I didn't want to recompile every template every time, just the one I am using at the moment.

(Note: I used queryF() rather than query() because I need to perform this function in querystring-based pages. This can be considered a minor security issue, I know, but I do not plan to have this code called EVER once the site goes live.)

function recompileTemplate($dirpath,$fileName) {
    Global 
$xoopsDB,$xoopsTpl;
//1. get tpl_id based on filename
    
$sql "SELECT tpl_id FROM ".$xoopsDB->prefix("tplfile").
           
" WHERE tpl_file = '".$fileName."'";
    
$result $xoopsDB->queryF($sql);
    list(
$tpl_id) = $xoopsDB->fetchRow($result);

//2. read file into memory
    
$path XOOPS_ROOT_PATH.'/modules/'.$dirpath.'/templates/'.$fileName;
    
$lines file($path);
    
$filecontents '';
    
$count count($lines);
    for (
$i 0$i $count$i++) {
        
$filecontents .= str_replace("n""rn"str_replace("rn""n"$lines[$i]));
    }
    
//3. update tplsource with new template
    
$sql "UPDATE ".$xoopsDB->prefix("tplsource").
           
" SET tpl_source =".$xoopsDB->quoteString($filecontents).
           
" WHERE tpl_id = ".$tpl_id;
      if (!
$result $xoopsDB->queryF($sql)) {
         return 
false;
    } 
    
//4. recompile template
    
include_once XOOPS_ROOT_PATH."/class/template.php";
    
xoops_template_touch($tpl_id);
    
    return 
true;
}



37
phatjew
Re: UML diagram for XOOPS objects?
  • 2003/11/19 13:58

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


It is also in the Wiki, along with some documentation and comments:

http://wiki.xoops.org/wakka.php?wakka=XoopsFormLibrary

However, this is only for xoopsForm, not xoopsObject.



38
phatjew
Re: template not automatically recompiled
  • 2003/11/18 19:44

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Quote:

MithyT2 wrote:
There is a smarty variable, which can force a compile ($force_compile if I am not mistaken) which does exactly that - but the problem is that the templates in XOOPS are moved to the database, so it needs a bit of extra work here.

but as you say, most code is written... maybe possible to extend to module area.



I'd be willing to give it a shot if someone could point me in the right direction. I just haven't done a whole lot of excavating through the XOOPS core, so I'm not sure where to start.

Quote:

What is really a bitch is if you use a non-default template set on your site Cause on module update, it updates the default template in database only.


Not a problem for me -- defaults all the way!



39
phatjew
Re: template not automatically recompiled
  • 2003/11/18 19:09

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


Holy Crap! It's in the Wiki!


Quote:

'theme_fromfile' - when set to "1", XOOPS automatically checks your theme files to see if they have been update; if so, database templates are updated


If only there was something that checked a module's template files, not just the theme template file. It seems like most of the code is already written . . .




40
phatjew
Re: template not automatically recompiled
  • 2003/11/18 19:01

  • phatjew

  • Just popping in

  • Posts: 56

  • Since: 2003/10/8


OK, fair enough.

Is there a way to invoke some XOOPS code to recompile the templates EVERY TIME a page is loaded? I am thinking about a line like:

$xoopsOption['compile_templates'] = 'true';

I could use this during development, then comment it out or delete it once I am finished.

Does anything like this exist?




TopTop
« 1 2 3 (4) 5 6 »



Login

Who's Online

280 user(s) are online (166 user(s) are browsing Support Forums)


Members: 0


Guests: 280


more...

Donat-O-Meter

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

Latest GitHub Commits