Welcome, Guest. Please login or register.
Did you miss your activation email?
February 13, 2012, 01:08:27 AM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
149699 Posts in 21103 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Calling external PHP apps as part of the WB Wrapper they're meant for  (Read 758 times)
Harry P.

Offline Offline

Posts: 84


« on: January 31, 2010, 07:24:07 PM »

Hello All,

as an add-on to my WB project, I've written a small PHP application, a recipe database. It simply displays a recipe, pulled from a table, based on an ID, like this:

www.xyz.com/rezept.php?ID=15

With WB's WRAPPER page mode it was easy to embed the display of such recipe pages into my WB project.

What puzzles me thoughis how to get the external program results displayed within the template when call from elsewhere.
Neither links from other WB (WYSIWYG) pages nor other programs will show it within the WB template (I'd also like to display recipes in their WB wrapper when called from our Web shop, for example, rather than displayed stand-alone).

Any helpful hints appreciated...
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #1 on: January 31, 2010, 07:37:06 PM »

I think your script needs the DB since WB needs the db as well and the db is set at the start your db calls might unset these, reset the db class WB uses.

Something like

your script... ... ... ...
when ready call
    // Create database class
    $database = new database();


Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Harry P.

Offline Offline

Posts: 84


« Reply #2 on: January 31, 2010, 08:17:56 PM »

Thanks John.

You think I need to do this although that other database is in a completely different database, i.e. independent from any WB DB stuff??

Can't I somehow call the external app in a way the WRAPPER page does?

(my first WB project and also new a PHP newby, that's why I'm a little confused)



« Last Edit: January 31, 2010, 08:22:38 PM by Harry P. » Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #3 on: January 31, 2010, 08:59:54 PM »

Sure it does, unsetting the db class in wb, even if it is in another database

Just look at  your app: rezept.php, at the end add something like

Code:
// Recreate WB database class
$database = new database();

Make sure this is within the <?php tags

Then you can copy paste the content of rezept.php in a code section (make a new page type code)

Have fun,
John
Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Harry P.

Offline Offline

Posts: 84


« Reply #4 on: February 01, 2010, 06:48:20 PM »

John,

I installed my PHP database code as a WB CODE-type page, and adding $database = new database(); to the end of my code page did indeed the trick. I'm impressed!

And I was happy to find out that a CODE page, e.g. to display a specific record, can be called from outside with a parameter, in my case /pages/showrecipe.php?ID=nnn

And from within WB WYSIWYG pages, I found that I can use refs like [wblink220]?ID=123 to supply a parameter. Live and learn.

Problem solved - thanks for your help!  smiley
Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #5 on: February 01, 2010, 08:09:07 PM »

Next discover droplets.... wink

have fun
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Harry P.

Offline Offline

Posts: 84


« Reply #6 on: February 02, 2010, 11:18:33 AM »

Quote
Next discover droplets...

Oh, I did already. In fact, it is hard to resist "droplet-o-mania"  grin

WB rules. (and so does this community)
Logged
Harry P.

Offline Offline

Posts: 84


« Reply #7 on: February 02, 2010, 02:24:32 PM »

Well, with Droplets, I ran into another problem (related, hence no new thread)

I have two DBs to display records from, with, say dbase1.php?=123 and dbase2.php?=456
(shown here with sample parameters they're called with)

I created two Droplets, for a syntax DBLink1 and DBLink2.

Code für Droplet #1:
Code:
return '<a href="dbase1.php?ID='.$ID.'">Linktext1</a>';

Code für Droplet #2:
Code:
return '<a href="dbase2.php?ID='.$ID.'">Linktext2</a>';

Usage:

[[DBLink1?ID=nnn]]   or  [[DBLink2?ID=nnn]]  respectively.

Now, if I drop these on a WYSWYG page...

Code:
[[DBLink1?ID=42]]

Code:
[[DBLink2?ID=25]]

... both resulting links contain the parameter"42"!  sad

Suspecting some unflushed buffer, I tried adding commands like ob_end_flush(), ob_flush() flush(), ob_start()  and ob_get_clean() but that didn't help.

Any idea? John?
« Last Edit: February 02, 2010, 02:27:27 PM by Harry P. » Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #8 on: February 02, 2010, 05:18:35 PM »

Yups

Have a look at: http://www.websitebakers.com/pages/droplets/module-wb2.8.php
Update the droplets module, problem solved.


Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Harry P.

Offline Offline

Posts: 84


« Reply #9 on: February 02, 2010, 07:07:26 PM »

John,

you were right - that solved it. Thanks!

I'd also like to share a WB beginner's problems with the module upgrade process, though, in particular with this Droplets upgrade.

Since I didn't find any upgrade info for Droplets, I went ahead and uninstalled the current version under WB Admin.

Then I installed the new 1.02 version.

That went fine, except that all my self-written Droplets were gone!  shocked

Fortunately, I had discovered Droplets' Save to ZIP function and used it before uninstalling Droplets 1.01. So at least I had a backup. I noticed they were all there, as separate files.

So I unzipped/copied all my stuff to the /example folder, hoping my own droplets would show up in WB. But they didn't.

I looked at Droplets' install.php program, which even talks about importing all droplets from the /example folder. But it didn't, instead I got redirected to the root (start page).

So I went ahead and opened every single file and recreated my Droplets, one after another.

Two questions arise:

1. What is the "official" way to upgrade Droplets (and any other add-on module, for that matter)?

2. Is there a way to import the ZIP-saved Droplets? (I would guess so)

Bonus question: Is there a utility that checks a complete WB installation if for updates are available for any installed add-on?
« Last Edit: February 02, 2010, 07:13:11 PM by Harry P. » Logged
pcwacht
AddOn Development
*
Offline Offline

Posts: 2814



WWW
« Reply #10 on: February 03, 2010, 10:11:11 AM »

1 official way depends on the module or more precise to its writer
2 droplets should be core, so update is installing over the exisiting, no need to uninstall unless stated otherwise

The official way is just install the new addon without uninstalling the old one, wb will see the exisiting and will call the upgrade script instead of the install script when it is a module, when it is a template it will overwrite exisiting files. Most core modules  and other addons works this way.
And allways check the addon for instructions when updating!!!!

bonus, nope, not official anyway, though something exists in the forum wich checks current versions with a website to see if there are updates here is more info:
http://slink2.no-ip.info/pages/website-baker-info/module-mods/module-version-checker.php




Have fun!
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
Harry P.

Offline Offline

Posts: 84


« Reply #11 on: February 05, 2010, 11:50:19 AM »

Thanks, John!

I suggest such a "Module Version Checker" should be part of future WB versions.
« Last Edit: February 05, 2010, 11:52:30 AM by Harry P. » Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!