21
worlds
Reloading templates fails. Sometimes...
  • 2004/4/2 11:27

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Hi -

I'm seem to be losing a block, when I reload a module. I see this on the output from the reload:

Block Bookstore: Titles deleted. Block ID: 563
Block template bookstore_title.html deprecated.

Then when I hit reload again, I the block is just not listed at all in the output from reload.

The block definition looks like this:

// Blocks
$modversion['blocks'][0]['file'] = "bookstore.php";
$modversion['blocks'][0]['name'] = _MI_BOOKSTORE_TITLES;
$modversion['blocks'][0]['description'] = _MI_BOOKSTORE_TITLES_DESC;
$modversion['blocks'][0]['show_func'] = "b_bookstore_show_titles";
$modversion['blocks'][0]['template'] = 'bookstore_title.html';
// options: max title length displayed |
$modversion['blocks'][0]['options'] = 16;

$modversion['blocks'][1]['file'] = "bookstore.php";
$modversion['blocks'][1]['name'] = _MI_BOOKSTORE_COVERS;
$modversion['blocks'][1]['description'] = _MI_BOOKSTORE_COVERS_DESC;
$modversion['blocks'][1]['show_func'] = "b_bookstore_show_covers";
$modversion['blocks'][1]['template'] = 'bookstore_cover.html';
...
and so on.

There are no other occurances of ['blocks'][0] anywhere in the file.

Any ideas where to start?

Thanks,

Tom



22
worlds
Re: Multilingo for the bookstore?
  • 2004/4/2 11:06

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Hey, I'd like to help, but I'm not sure I fully understand the problem. Should I be doing someting different to make the module internatioanlizable?

What exactly does 'multillingo' mean? Is it more than just having the language/english files translated into another language?

Let me know how I can help.

Tom



23
worlds
Re: Amazon, Hot or Not, phpNuke and Xoops
  • 2004/3/29 19:51

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Well, you can try my Amazon module.

It's available athttp://www.worldware.com/modules/mydownloads/

It's running athttp://www.worldware.com

It's fairly simple still, but being actively developed. Feature and other suggestions are encouraged.

Tom



24
worlds
Re: Start Page, Anonymous: Advice needed
  • 2004/3/29 5:12

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Hi -

You do know that block visibility & module access for anonymous users are set under admin, groups, Anonymous Users, modify?

Check both module access rights and block access rights.

Please excuse me if I'm stating the obvious, but it took me a bit to figure that out.

Tom




25
worlds
Sorting lists in the admin web interface
  • 2004/3/22 20:38

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Hi -

Would it be a good idea to sort lists of blocks, modules, etc., in the admin interface?

It just seems to be more convenient if they are alphabetized.

For example, if you add this code to blocksadmin.php, replacing line 116: "foreach (array_keys($block_arr) as $i) {"

// Sort blocks by name
$original_keys = array_keys($block_arr);
$sorted_keys = array();
foreach ($original_keys as $i)
$sorted_keys[$i] = $block_arr[$i]->getVar("name");
asort($sorted_keys);

foreach ($sorted_keys as $i => $notusedatall) {

The list of blocks is alphabetized by name, which I find saves me time.

Tom



26
worlds
Re: PHP globals question. _solved
  • 2004/3/22 19:49

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Hi -

It appears that the problem is that the code for blocks is actually included by XOOPS WITHIN A FUNCTION.

Note that I have not found this in the XOOPS code yet, but it sure seems to behave that way.

The results is that the variables in the included file, that I thought were being included at global scope, actually end up being defined within a function.

Which means that when I tried to access these variable as globals, they weren't there, because they were declared within the enclosing function, not at global scope.

So the fix is to manually put the variables declared in the included files into $GLOBALS, and then things work, whether the code is included a global scope, or within a function

$bookstore_config_info_ = array(...);
$GLOBALS["bookstore_config_info"] = $bookstore_config_info_;

So, I have two questions.
1) If someone knows the XOOPS code better than I can tell me whather my conclusions are correct. (Or just point me to the right part of the code...)

2) Is there a way for a nested function to access the variables declared in the enclosing function? (I'm just curious, this workaround means I don't need to know).

Tom
www.worldware.com



27
worlds
Re: PHP globals question.
  • 2004/3/19 18:03

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Thanks for the quick response.

So, forget about the multiple modules. I've attached code for a block below. As it is, it works. If I move $bfp out of the function, and uncomment the global $bfp it doesn't. I'm sure I'm doing something obvious and dumb, but I think that should work.

Of course, I've been programming in PHP for only a few weeks, so my opinion doesn't count for much

I I cut and paste the code into my admin/index.php, it seems to work there. Is there something different about the execution environment of blocks?


Thanks,

Tom


-----------------------------------
<?php
// Gets the value as a string. If the value is an array, it concatenates the elements, separated by commas
function bookstore_get_value($v)
{
if (!is_array($v))
return $v;
$str = "";
$first = true;
foreach($v as $i)
{
if (!$first)
$str .= ", ";
$str .= $i;
$first = false;
}
return $str;
}


function b_bookstore_show()
{
global $xoopsDB;
// global $bfp;
$bfp = array("ProductName", "SalesRank", "Asin", "Url", "ImageUrlMedium", "Authors", "ReleaseDate", "Catalog", "OurPrice", "Manufacturer");

$block = array();
$queryString = 'SELECT ' . bookstore_get_value($bfp) . ' FROM ' . $xoopsDB->prefix('bookstore_product') . " ORDER BY $bfp[0] ASC";
$result = $xoopsDB->query($queryString);
while ($values = $xoopsDB->fetchRow($result))
{
$link = array();
for ($i = 0; $i < count($bfp); $i++)
{
$link[$bfp[$i]] = $values[$i];
}
$block['links'][] = $link;
}
return $block;
}
?>




28
worlds
PHP globals question.
  • 2004/3/19 6:48

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Hi -

I'm doing something that should be simple. I declare an array in one file, and then include it from several other files.

Works great. Except in the file for my blocks. The first lines of code are identical, and yet, it works when included in my admin/index.php, and index.php, but not from blocks/foo.php. Clearly something I don't understand.

The files (now) start with identical code, (except the path to mainfile.php) to print out all globals. In two modules, I see exactly what I expect. In the third, the global I'm looking for is simply not in the $GLOBALS array.

Now, interestingly, I can print the variable at global scope, but not within the function, even with the global declaration.

I know the file is getting successfully included, since I have an 'echo' statement in the included file.

They all start with:

require "mainfile.php";
require_once(XOOPS_ROOT_PATH ."/modules/bookstore/myfunctions.php");

echo "<P>Global scope, \$bookstore_fields_p='$bookstore_fields_p'</P>";
foreach($GLOBALS as $k => $v)
echo "<P><U>GLOBAL: $k => $v</U></P>";

But only two out of three show the variable I declare.

Anyone want to explain to me what I'm missing? I suspect it's something obvious, but I'm not seeing it.

Tom



29
worlds
Anyone have a script to reload modules?
  • 2004/3/18 21:44

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


Hi -

Ok, so I'm lazy, but I'm writing a module, and getting tired of:

Click to deactivate/click submit/click ok/click reload/click uninstall/click ok/click reload/click install/click ok/click reload.

It gets old after a few dozen iterations.

Does anyone have a handy script that will update a module (basically do what the clicks above do)?

I do know I only seem to have to do this when there are template changes. But it's still a lot.

Thanks,

Tom



30
worlds
Re: Uninstall/ change modules
  • 2004/3/18 18:02

  • worlds

  • Just popping in

  • Posts: 61

  • Since: 2004/3/13


If nothing is showing up, I sometimes find there is an syntax error in my PHP. PHP debug only seems to give messages if the file parses successfully. Things like missing quotes, etc, can cause blank screens with no PHP debug messages.

As simple check for this is to run php from the command line.

* Switch to the directory containing the file you are working with.
* php -f nameoffile.php

note that the file won't run correctly, since all of the server environment isn't set up. But it will check for syntax errors, and give you an error message.

Tom

Note that I'm a XOOPS newbie, and you shouldn't take anything I say too seriously.




TopTop
« 1 2 (3) 4 »



Login

Who's Online

261 user(s) are online (152 user(s) are browsing Support Forums)


Members: 0


Guests: 261


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