Share » Forums » Developer » How to pass variables via URL to tree...

How to pass variables via URL to tree nodes

How to pass variables via URL to tree nodes

Friday 20 November 2009 9:12:48 am - 3 replies

Author Message

Bertrand Dunogier

Friday 20 November 2009 11:31:40 am

Don't take this the wrong way, but you're doing it wrong. Really.

eZ Publish provides you with everything you need to integrate external databases. It will require a little more setup work, but you will end up with a much better integration.

What you need is a custom module with custom views. A view consists of a PHP script where you... well, you do whatever you want/can do with PHP. You also have the option to render your HTML using the standard eZ Publish template engine. You could for instance have a "list" view that displays a list of records, a "details" one that shows details about a record, etc. Views can accept parameters, like details/foo or details/1.

You can read the basics here: http://ezpedia.org/en/ez/module

If you integrate your database using the eZ Publish persistent object API, you will also be able to use your objects from templates like you would have done with any eZ Publish object (nodes, objects, etc).

P.S. eZ Publish itself is built using this module/view mechanism. Just check the kernel folder for some code ;)

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Erik Weinmaster

Friday 20 November 2009 2:23:00 pm

Bertrand,
Thanks for the quick reply. I understand the concept of what you stated in your reply with setting up a module with multiple views. However, I am having a little trouble getting started with the definitions in the module.php file.

After reading what you said and the directions from the link you provided, I have a module.php file setup in the extensions directory. This is where I get stuck... How do I link up the module.php file to a specific node (which can be reference by the class_identifier). What I would like is to use this module when the user clicks on my specifically named node. Thus if this click came from the content tree then there will not be any additional parameters so a list will show, and if the user clicks on a list item inside the node then the page will link to the new module with parameters and the details will show.

Right now I've only reached the point of defining the $ViewList array. So I have something that looks like this:

$ViewList['list'] = array(
'script' => 'list_view.php'
);
$ViewList['details'] = array(
'script' => 'details_view.php',
'unordered_params' => array( 'var1' => 'Var1',
'var2' => 'Var2' )
);

Bertrand Dunogier

Saturday 21 November 2009 12:36:42 am

You don't link to module.php. module.php is the module definition file.

In your case, to access your list, you just need to create a link to modulename/list. If your module's name is "externaldb", just use something like this:

<a href={'externaldb/list'|ezurl}>External DB</a>

Now you can just override your node view templates like you probably already did and create these links. Does this help ?

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu