September 02, 2010, 09:37:53 pm *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Dont forget to check the Facile Forms wiki !
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: getPageByName not working.  (Read 6319 times)
brunoreis
Newbie

Offline Offline

Posts: 8


« on: May 18, 2006, 10:36:43 pm »

I was studying the (very good by the way) Tutorial on Creating a Tag Board.
I created the piece to work before form to chose the right page. But It did not work, the method getPageByName did not exist.

So I found that there is a ff_getPageByName and even that I need to call
Code:
$this->execPieceByName('ff_InitLib');
to make it work. There were no more error messages, but it did not worked either... then I put some echos on the script:
Code:
echo "@1<br>";flush();
$this->execPieceByName('ff_InitLib');
echo "@2<br>";flush();
global $my, $exists;
$exists = 0;
//look through the tables to see if mos_tbd_tags is in the Mambo database.
$dataset = mysql_query('SHOW TABLES') ;
while( $row = mysql_fetch_row($dataset) )
{
if ( $row[0] == "mos_tbd_tags" ) {
$exists = 1;
break;
}
}
echo "exists=='".$exists."'<br>";
// if it exists got to page 1
if ( $exists == 1 ) {
        echo "@3<br>";flush();
$this->page = ff_getPageByName($this, 'ftb_intro');
// if it does not exist send the form to the correct page for user type
 } else {
if ($my->usertype == "superadministrator") {
                echo "@4<br>";flush();
$this->page = ff_getPageByName($this,'ftb_ctable');
} else {
                echo "@5<br>";flush();
$this->page = ff_getPageByName($this,'ftb_ntable');
}
}
echo "page=='".$this->page."'<br>";flush();

but looking at the form all I got was...

@1
@2
exists=='0'
@5
page==''

that means that the ff_getPageByName($this,'ftb_ntable'); did not return anithing.
But on page 3 I do have the following item:
    No Table     ftb_ntable     Static Text/HTML                    10px     0px     160

What is wrong?
Is there another way to use getPageByName?
Logged
facile
Administrator
Hero Member
*****
Offline Offline

Posts: 774



« Reply #1 on: May 18, 2006, 10:42:04 pm »

try ff_getPageByName('thename')
Logged

Peter
brunoreis
Newbie

Offline Offline

Posts: 8


« Reply #2 on: May 18, 2006, 11:53:14 pm »

It did not work. It did not returned the page number.

Is this the right use of this method: return the page where an element of a form is ?

Of course if I put

$this->page = 3

it will work, but

$this->page = ff_getPageByName('ftb_ntable');

won´t.

Please help me on that since this looks like a good method to be used.
Logged
facile
Administrator
Hero Member
*****
Offline Offline

Posts: 774



« Reply #3 on: May 19, 2006, 12:15:48 am »

I checked it, and it apprears to be a bug in the piece library. Obviously not a too heavy used function because it was not reported since last november Wink

Anyway, here is how you can fix it:

  • Click Manage Pieces
  • From the Package drop down select FF
  • Click on Get page # by element name
  • Add the global declaration for $ff_processor so the function looks as below
  • Save the piece

Code:
function ff_getPageByName($name)
{
    global $ff_processor;
    foreach($ff_processor->rows as $row)
        if ($row->name==$name)
            return $row->page;
    return null;
} // ff_getPageByName
« Last Edit: May 19, 2006, 12:20:45 am by facile » Logged

Peter
brunoreis
Newbie

Offline Offline

Posts: 8


« Reply #4 on: May 19, 2006, 03:55:37 pm »

Now it is ok. It worked just fine.

Thank for the help.

* by the way, I put a post on the tutorial linking to this topic.
Logged
jaquesa
Newbie

Offline Offline

Posts: 1


« Reply #5 on: June 13, 2006, 05:09:59 pm »

Hi,

I am trying the Tutorial but have got stuck at this point. I have added the 'global $ff_processor;' to the function still without luck.

One strange thing though is that the function name in the Piece Library is called ff_getPageByNameX (with an X at the end). I did not change this, it comes installed named this way...

I am using version 1.4.4, please someone help me get past this bug.

Alain.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF © 2001-2006 Lewis Media
| Terms of Use | Privacy | Sitemap |